Wordpress get_option from shortcode

末鹿安然 提交于 2019-12-23 04:36:08

问题


I want to be able to get some wordpress options with the shortcode from the post, something like this: [get_option posts_per_page]

Is there an easy way to do that?


回答1:


I think it is pretty easy

first, create a function that will handle the short code

 function handle_shortcode($para){
     //get_options
 }

secord, register the shortcode

add_shortcode('getOption', 'handle_shortcode');

then, use it in a post:

[getOption para="key"]

more details look at here: http://codex.wordpress.org/Shortcode_API



来源:https://stackoverflow.com/questions/8885007/wordpress-get-option-from-shortcode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!