3

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?

4

1 回答 1

3

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

于 2012-01-16T20:17:29.057 回答