Answer the question
In order to leave comments, you need to log in
How to exclude records of certain categories from the output?
@if (!have_posts())
<div class="alert alert-warning">
Ничего не найдено
</div>
{!! get_search_form(false) !!}
@else
<section class="last-series">
<div class="archive-cont columns">
@while (have_posts())
@php
the_post();
apply_filters( 'rb_issues_footer_id', [get_the_ID()] ); // add ID
@endphp
@include('partials.content-grid-'.get_post_type())
@endwhile
{{-- Print player script --}}
@php do_action( 'rb_issues_footer_out', apply_filters( 'rb_issues_footer_id', [] ) ); @endphp
</div>
</section>
@endif
Answer the question
In order to leave comments, you need to log in
Here is an example of how to exclude posts of certain categories on archive pages
add_action( 'pre_get_posts', 'exclude_category' );
function exclude_category( $query ) {
if ( $query->is_archive() && $query->is_main_query() ) {
$query->set( 'cat', '-1,-1347' );
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question