我正在為博客使用自定義頁面(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 回答
- 0 關注
- 176 瀏覽
添加回答
舉報
0/150
提交
取消