问题
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