我正在为博客使用自定义页面(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;
- 1 回答
- 0 关注
- 160 浏览
添加回答
举报
0/150
提交
取消