WordPress在archive.php页面获取文章列表

除了使用WP_Query函数之外,还可以使用query_posts函数来查询,如下:

<?php
query_posts(array(
    'post_type'   => 'case', // You can add a custom post type if you like
    'paged'     => get_query_var('paged', 1),
    'posts_per_page' => 1
));

while (have_posts()) :
    the_post();
?>
    <a href="<?php the_permalink() ?>" class="col-xs-12 col-sm-4 col-md-4 col-lg-4 block-four-list">
        <div class="block-four-list-wrap">
            <img src="<?php echo catch_that_image(); ?>" alt="">
            <div class="infos-right-view2 about-a-infos">
                <h5>成功案例</h5>
                <h1><?php the_title() ?></h1>
                <span class="a-more-4">了解更多<i class="iconfont icon-youjiantou6"></i></span>
            </div>
        </div>
    </a>


<?php
endwhile;

?>

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注