WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Hook add filter to the content and exclude posts from a certain category

[Resolved] Hook add filter to the content and exclude posts from a certain category

  • Leon

    @leondoornkamp

    Hi,

    I am adding a filter to the content with my plugin, which adds a link to certain keywords.

    Now I want to exclude certain posts which are in a particular category.

    In other ways, only apply the filter to posts which are not in that category. Anybody knows if this is possible?

    function filter_content()
    {
     //content stuff here
    }
    
    add_filter('the_content', 'filter_content', 999);

    thanks!

Viewing 1 replies (of 1 total)
  • Leon

    @leondoornkamp

    I found a way to do this,

    in the function that filters add the following:

    $get_category = get_the_category();
    if(strtolower($get_category[0]->cat_name) != 'catname')
    {
    //the actions to perfom on the content
    }

    this only applies when the certain category you want to exlcude is the first category assigned to the post. If you want to exclude more, you can do an array search.

Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] Hook add filter to the content and exclude posts from a certain category’ is closed to new replies.
Skip to toolbar