WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Add a Filter Conditionally? (1 post)

  1. golddave
    Member
    Posted 6 years ago #

    I'm writing a plugin that has an option to be called through a template tag or to be called "automatically". When it is called "automatically" the plugin adds some text after the post. This option is applied using a filter as follows:
    add_filter('the_content', 'add_some_text');

    I would like this filter to be conditional so that it doesn't get run when the option is set to use the template tag but have had trouble setting it up. I have tried to do an if statement (if option is set to automatic) and that has not worked. Can a filter be set conditionally? Or do I need to create two versions of this plugin?

    Thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic