开发者

Get a value in a wordpress form

This is a sample input form from wordpress standard coding (I get it from this page - http://codex.wor开发者_如何转开发dpress.org/Creating_Options_Pages)

<input type="text" name="new_option_name" value="<?php echo get_option('new_option_name'); ?>" />

When people insert the data in the form, the value will store in the function

<?php echo get_option('new_option_name'); ?>

My question is, how to get back the value to display the anywhere like index.php, sidebar.php so in can be viewed by the public.


Technically, you use the function update_option('new_option_name','New option value'); to store the data. You can use the get_option('new_option_name'); function to access that data anywhere in WordPress (well, any time after the plugins have loaded, at least. Maybe sooner). So you can put echo get_option('new_option_name'); anywhere in your theme and it will work as long as the option with the name 'new_option_name' actually exists.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜