Remove category posts specifies wordpress

Asked

Viewed 178 times

0

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

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'
));

Shapes I’m trying to make:

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 none of those ways worked. I thank friends who can give me a strength.

  • Young this kind of thing you usually do right by the administrator area, in the plugin options etc. You can also try to create a new category, and move all posts from 764 to this new category, after that derepost 764 to see if it solves.

  • There is no such option, friend. I created the new category and it still didn’t work.

  • Someone to help me?

1 answer

1


Check out the Codex: http://codex.wordpress.org/Custom_Queries#Category_Exclusion

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
   
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.