Answer the question
In order to leave comments, you need to log in
How to prevent posts from a certain category in Wordpress?
I have 2 types of custom posts on a Wordpress site - Location and Event . Location is associated with Event as one of the meta fields (for sorting purposes). That is, for example, such and such an event (event) takes place in Moscow (Location). Location data (binding to Location Moscow) is written in the meta field of the Event post. On the Location Moscow
post page , all Event posts that have the Moscow attribute in the corresponding meta field are displayed. The problem is that all possible categories of Event posts are displayed there. I need to disallow one category (custom post type category) to be displayed on this page.
Now the code is like this:
$count = 0;
$paged = 1;
if ( get_query_var( 'paged' ) ) {
$paged = get_query_var( 'paged' );
}
$args = array(
'post_type' => 'event',
'paged' => $paged,
'meta_query' => array(
array( 'key' => 'location', 'value' => get_the_ID() ),
),
);
$tmp_query;
global $wp_query;
$the_query = new WP_Query( $args );
$post_ids = array();
if ( $the_query->have_posts() ) :
if ( $template_type == 1) {
while ( $the_query->have_posts() ) :
$the_query->the_post();
echo event();
endwhile;
}
Answer the question
In order to leave comments, you need to log in
in
'cat' => -2136 arguments,
this will exclude nested ones as well.
To not exclude nested ones, then 'category__not_in'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question