I'm wanting to include a function into a WordPress page, but since WordPress doesn't allow the use of <?php ?>
tags I cannot add the functions regularly.
I noticed when using a gallery plugin that it added [flagallery gid=1 name="Gallery"]
to the page content (when editing the page in visual mode). Is there some way to set this up in my plugin?
Like on my page have [myPlugin category=myCategory]
run:
function myPlugin($category) {
echo ...
}
They're called shortcodes.
This link should tell everything you need to know to get started with them: http://codex.wordpress.org/Shortcode_API
Pseudo example:
function category( $cat ) {
extract( shortcode_atts( array(
'cat' => 'something'
), $atts ) );
return "category is {$cat}";
}
add_shortcode( 'myPlugin', 'category' );