亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在自定義博客頁面模板中添加分頁

在自定義博客頁面模板中添加分頁

PHP
慕村225694 2021-10-22 16:47:10
我正在為博客使用自定義頁面(page-allblogs.php)。我沒有寫這個頁面中的所有代碼,因為我想寫干凈的代碼。所以這個頁面有以下代碼:<?php get_header();?><?php get_template_part('navigation'); ?><?php get_template_part('blogslist'); ?><?php get_footer();?>博客列表的主要代碼在頁面 bloglist.php<div class="col-md-9">        <!-- INDIVIDUAL BLOG ITEM LIST -->          <?php            $args = array(            'posts_per_page' => 2,            'post_type'     => 'blog',             'orderby'       => 'date',            'order'         => 'DESC'             );            $loop = new WP_Query($args);            if($loop->have_posts()) {            while($loop->have_posts()) : $loop->the_post();          ?>          <div class="blog-item">          <div class="blog-item__top">            <div class="blog-item__image">              <a href="<?php the_permalink();?>">                <?php $image = get_field('image');                if( !empty($image) ): ?>                  <img src="<?php echo $image['url']; ?>" class="img-responsive" alt="<?php echo $image['alt']; ?>" />                <?php endif; ?>              </a>            </div>            <div class="blog-item__detail">              <ul>                <li><a href="#"><i class="fa fa-calendar" aria-hidden="true"></i><?php the_time('M j, Y');?></a></li>                <li><a href="#"><i class="fa fa-thumbs-up" aria-hidden="true"></i>201 LIKES</a></li>                <li><a href="#"><i class="fa fa-comment" aria-hidden="true"></i>15 COMMENTS</a></li>              </ul>            </div>          </div>我正在使用 wpbeginner 的分頁代碼,我已經把它放在了functions.php 中。
查看完整描述

1 回答

?
倚天杖

TA貢獻1828條經驗 獲得超3個贊

我在 $args 中錯過了這個。

$paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1;


查看完整回答
反對 回復 2021-10-22
  • 1 回答
  • 0 關注
  • 176 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號