简码中的Wordpress get_option [英] Wordpress get_option from shortcode
本文介绍了简码中的Wordpress get_option的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望能够从帖子中获得一些带有简码的wordpress选项,如下所示: [get_option posts_per_page]
I want to be able to get some wordpress options with the shortcode from the post, something like this: [get_option posts_per_page]
有一种简单的方法吗?
推荐答案
我认为这很简单
首先,创建一个处理短代码的函数
first, create a function that will handle the short code
function handle_shortcode($para){
//get_options
}
secord,注册简码
secord, register the shortcode
add_shortcode('getOption', 'handle_shortcode');
然后,在帖子中使用它:
then, use it in a post:
[getOption para="key"]
更多详细信息请参见此处: http://codex.wordpress.org/Shortcode_API
more details look at here: http://codex.wordpress.org/Shortcode_API
这篇关于简码中的Wordpress get_option的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文