Support » Fixing WordPress » Trouble with add_filter

  • Hi everyone!

    I’m writing my first plugin and I have to face with probably small problem. I have such a code:
    add_filter( 'the_content', 'my_func' );
    And it works, but when I put something like this:

    if( is_page() )
      add_filter( 'the_content', 'my_func' );

    It doesn’t work. The question is of course “why?”.

    And BTW: I check if is it a static page or post by checking post_type in DB. Is there any better solution?

    Thanks in advance for any help!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Is there any better solution?

    I dont know about better, but there is another way — dont put page checking in your plugin. Write the plugin, then call the plugin based on is_page.

    It’s good idea too. But what about the first question? Why doesn’t it work?

    I made my own is_page() function but didn’t overload the built-in one, it is why it didn’t work 😉

    Hi, masterix! Did you find a way for you problem? I get this one and can’t find solution on forum 🙁

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Trouble with add_filter’ is closed to new replies.