开发者

WordPress ShortTag Custom Variable

开发者 https://www.devze.com 2023-02-14 10:58 出处:网络
I like to have a whole website build in wordpress. All through the site there will be telephone number, address,开发者_Go百科 some link here and there...

I like to have a whole website build in wordpress. All through the site there will be telephone number, address,开发者_Go百科 some link here and there...

I like to be able to defin variable shorttag in the admin panel somewhere, and be able to insert it in the WYSIWYG like that :

you can contact us anytime [phone] or visit us here : [address]

so changing addres or number is a snap !

any idea, i got http://wordpress.org/extend/plugins/custom-configs/screenshots/ but need to insert in php not shorttag...


You can use the do_shortcode() function to output the shortcode values using php. Assuming that

Example:

<? echo do_shortcode('[phone]'); ?>

Using your plugin is easy to define shortcodes that are outputting the content of a custom setting

function get_phone($atts, $content = null) {
 return get_config('phone-settings');
}
add_shortcode('phone', 'get_phone');

Assuming that in your plugins, you have defined a custom settings with the key phone-settings

0

精彩评论

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