Remove posts from category specific wordpress

0

Hello, I downloaded the dooplay theme and I'm trying to remove from a widget posts that are category 764, but I have not had success so far, could you help me with it?

This is the original query code:

query_posts(array(
    'post_type' => array(
        'movies',
        'tvshows'
    ) ,
    'showposts' => $num,
    'meta_key' => 'end_time',
    'meta_compare' => '>=',
    'meta_value' => time() ,
    'meta_key' => $keybox,
    'orderby' => 'meta_value_num',
    'order' => 'DESC'
));

Forms I'm trying to do:

query_posts(array(
    'post_type' => array(
        'movies',
        'tvshows'
    ),
    'category__not_in' => array(764),
    'showposts' => $num,
    'meta_key' => 'end_time',
    'meta_compare' => '>=',
    'meta_value' => time() ,
    'meta_key' => $keybox,
    'orderby' => 'meta_value_num',
    'order' => 'DESC'
));

I also used

  

'cat' = > '-764'

But neither of these worked. I thank my friends for giving me strength.

    
asked by anonymous 15.02.2018 / 04:37

1 answer

1

Check the codex: link

You can use in loop arguments:

  

'category__not_in' = > '-764'

Or create an action in your functions.php

add_action('pre_get_posts', 'wpc_764' );

function wpc_764( $wp_query ) { // deve ser o nome da sua query, preferencialmente único, pois vai alterar em todas as $wp_query
   
    $excluded = array(764);  // coloca num array, caso vc precise excluir mais de uma.
   
    set_query_var('category__not_in', $excluded); // Adiciona category__not_in na query
   
}
    
18.02.2018 / 19:05