Filter the_content only when outputting full content? (4 posts)

  1. micropat
    Posted 7 years ago #

    Is there any way for a plugin filter function to detect when the_content is being called within a post or page only?

    For instance, when the_excerpt_rss() is called from another plugin or theme, it also calls the_content so my filter gets loaded.

    The problem is that my filter should only run when the_content is actually outputting the content (in full) on the page.

    Is there any way to detect this, or possible workarounds?

  2. micropat
    Posted 7 years ago #

    This would obviously not be a good idea to use in the plugin, but iterating through debug_backtrace() came to mind as a possible technical option.

    Anything else come to mind?

  3. Migweld
    Posted 7 years ago #

    I read in a nettuts tutorial that you can use

    return (is_single()) ? $variableName

    at the end of your plugin to return the filtered text only when the post is viewed in full. Hope that helps.

  4. micropat
    Posted 7 years ago #

    Hi Migweld, thanks for trying to help. :) Unfortunately the filter needs to function on the front page as well, not just single pages.

    Other ideas?

Topic Closed

This topic has been closed to new replies.

About this Topic