Answer the question
In order to leave comments, you need to log in
How to display records of category 1 in archives?
Hello.
I have a page with archives. The code:
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'entry' ); ?>
<?php endwhile; endif; ?>
<?php get_template_part( 'nav', 'below' ); ?>
<?php query_posts( 'cat=2' );
if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'entry' ); ?>
<?php endwhile; endif; ?>
<?php get_template_part( 'nav', 'below' ); ?>
Answer the question
In order to leave comments, you need to log in
You can exclude unnecessary categories on the pre_get_posts hook
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