I’m writing a plugin that adds a page with a tag [deposit_page]; that tag should be replaced with some PHP code.
This is what I have, but it doesn’t work. Is there something I’m missing or doing wrong?
function deposit_page_content($content) {
$deposit_page_content = "here will go the content that should replace the tags";//end of variable deposit_page_content
$content=str_ireplace('[deposit_page]',$deposit_page_content,$content);
return $content;
}
add_filter("the_content", "deposit_page_content");
I just noticed I gave the same variable name to the content that should replace the tag and the function itself. Could this be the problem?
WordPress has support for
[square_bracket_shortcodes]built in.See: http://codex.wordpress.org/Shortcode_API
Here is your simple example:
You can paste this into your active theme’s
functions.phpfile.If you wanted attributes, like
[my_shortcode foo=bar], you’d do, at the top of this function: