Use the [insert]
shortcode inside posts or anywhere else that processes shortcodes.
- query - sets up a new
WP_Query
viaget_posts()
- data - data to pass to actions
- action - action to run, runs for each post if applicable
- filter - filter to run, runs for each post if applicable
- template - template to load via
locate_template()
All attributes are optional and can be used in combination to yield powerful abilities.
Possibilities with [insert]
are endless. Practical uses include:
- Insert posts into posts
- Insert hooks into posts
- Insert posts into widgets
- Run action hooks via widgets
- Load templates via widgets
[insert template="branding.php"]
[insert action="dostuff"]
[insert data="field=slug&value=example&tax=category" action="dostuff"]
The action receives data as an array.
add_action('dostuff', 'print_r');
[insert query="name=about&post_type=page" template="entry.php"]
This sets up the query and triggers the action.
[insert query="name=about&post_type=page" action="dostuff"]
WP template tags are available inside the action.
add_action('dostuff', 'the_title');
MIT