• Resolved dwheeler

    (@dwheeler)


    I’m try to exclude certain categories from results and only go back 30 days.

    I modified the filter code from your webpage and ended up with

    add_filter('related_post_query_args','related_post_query_args_20200126');
    
    function related_post_query_args_20200126($args) {
        $args[s] = array(
        'category__not_in' => array('111','582'),
    		'date_query' => array(
            'after' => date('Y-m-d', strtotime('-30 days')) ) ); // search term
        return $args;
    }

    It’s not working. suggestions?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author PickPlugins

    (@pickplugins)

    Thanks for your post, you code was wrong, please use following

    
    add_filter('related_post_query_args','related_post_query_args_20200126');
    
    function related_post_query_args_20200126($args) {
    
        // exclude caetgoryies
        $args['category__not_in'] = array(111, 582);
    
        // date query
        $args['date_query'] = array('after' => date('Y-m-d', strtotime('-30 days')) );
    
        return $args;
    }

    I haven’t tested your date query, please make sure it correct.

    REgards

    Thread Starter dwheeler

    (@dwheeler)

    It is still pulling in that category, even when I remove the date part.

    add_filter(‘related_post_query_args’,’related_post_query_args_20200515′);
    function related_post_query_args_20200515($args) {
    $args[s] = array(
    ‘category__not_in’ => array(‘111′,’582’)
    ); // search term
    return $args;
    }

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Exclude Categories from resulsts’ is closed to new replies.