我无法在WordPress的archive.php
页上显示分页,我有2个查询,一个是2个帖子,另一个是12个,但是我的分页根本没有作用,我使用wpbegginer分页
<?php
$featured[] = '';
$args1 = array(
'cat' => get_query_var( 'cat' ),
'posts_per_page' => 2,
'ignore_sticky_posts' => 2,
'order' => 'DESC',
'orderby' => 'date'
);
$query = new WP_Query( $args1 );?>
@while($query->have_posts()) @php $query->the_post() @endphp
<?php the_title() ?>
<?php $featured[] = get_the_ID(); ?>
@endwhile
@php wp_reset_postdata(); @endphp
//second query
<?php $cat_id = get_query_var( 'cat' );?>
<?php $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1; ?>
@php $args2 = array (
'post__not_in' => $featured,
'posts_per_page' => 12,
'ignore_sticky_posts' => 1,
'post_type' => 'post',
'paged' => $paged,
'cat' => $cat_id
); @endphp
<?php
$temp = $wp_query;
$wp_query = null;
$wp_query = new WP_Query();
$wp_query->query( $args2 );
while ($wp_query->have_posts()) : $wp_query->the_post();?>
<?php the_title(); ?>
<?php endwhile; ?>
<?php
$wp_query = null;
$wp_query = $temp; // Resetujemo wp_query
?>
@php wp_reset_postdata(); @endphp
<?php echo wpbeginner_numeric_posts_nav(); ?>