I’m writing a plugin that adds some custom content near the end of a post (or page). So I’ve added a filter for ‘the_content’, and the plugin adds its content there. Mostly, it works.
However, some sites show the entire content of several posts on the homepage (rather than just excerpts). On those sites, my filter is being called once for every post that is displayed. So the custom content shows up more than once.
Is there some way for me to detect when my filter is a nested call? I.e. that it is being called for the content of a post which is being displayed on the homepage. I could then add my custom content only when it is a “top level” call.
I also considered attaching my filter to the footer instead of the content, but I’ve run across themes that don’t have a footer.
Thanks!
Ken
Single filter call
Just give this plugin a try. It illustrates the whole technique.
If you’re not targeting the content itself, but more the LOOP, then try this example plugin.
Incomplete Themes
Never ever even dare to think about caring for incomplete themes. We got Theme development guidelines for a reason and a call to
wp_footer();
is a must have for every theme. Else, just think “it’s crap!” by yourself and move on.