dqzuo0327 2018-11-08 12:25
浏览 34

分页不适用于自定义类别

I'm having trouble with showing pagination on the archive.php page for WordPress, I have 2 queries, one is for 2 posts and other one is for 12, but my pagination isnt workign at all, i'm using wpbegginer pagination

<?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(); ?>
  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作