• Resolved bdeirhiba990

    (@bdeirhiba990)


    Hello, I already commented on this issue on a thread but later discovered that it is resolved so just to be sure that the plugin support will see my issue here it is:

    I want to exclude posts having only 1 specific category from showing in related posts. for example, if the post has categories “a” and “b”, I want to exclude category “a” from showing so I used this code according to a link mentioned by the support:

    add_filter(‘related_post_query_args’,’related_post_query_args_20200126′);
    
    function related_post_query_args_20200126($args) {
    
    // exclude categories
    $args[‘category__not_in’] = array(3748);//3748 is id for category b
    
    return $args;
    }

    But the problem is no related posts are showing even if the post has a category “b”.
    Any help would be appreciated!
    Thank you!

    • This topic was modified 3 years, 3 months ago by bdeirhiba990.
Viewing 1 replies (of 1 total)
  • Plugin Support hasanrang05

    (@hasanrang05)

    I just tried the code its workig fine,

    i can see there was issue with quotes, could you please try following

    
    
    add_filter('related_post_query_args','related_post_query_args_20200126');
    
    function related_post_query_args_20200126($args){
    
    // exclude categories
        $args['category__not_in'] = array(190);//3748 is id for category b
    
        return $args;
    }
    • This reply was modified 3 years, 3 months ago by hasanrang05.
Viewing 1 replies (of 1 total)
  • The topic ‘No related posts is showing when exclude a category’ is closed to new replies.