wordpress文章列表倒叙输出 - 利剑分享-科技生活-利剑分享-科技生活
利剑分享-科技生活-利剑分享-科技生活
利剑分享-科技生活

wordpress文章列表倒叙输出

wordpress文章列表倒叙输出

wordpress网站文章列表倒叙输出的调用方法。

我们在做网站的时候,常常需要设置倒叙输出,特别类似于发展历程这种栏目。

可以用下面调用标题来替代默认的调用标签:

<?php if(have_posts()) : ?>
<?php $args = array( 'cat' => get_query_var('cat'),'numberposts' => 10, 'order' => 'asc', 'post_status' => 'publish');
$rand_posts = get_posts( $args );foreach( $rand_posts as $post ) : ?>

<?php endforeach; ?>
<?php endif; ?>

可以直接改成调用指定分类id的文章列表:

<?php if(have_posts()) : ?>
<?php $args = array( 'cat' => 72,'numberposts' => 20, 'order' => 'asc', 'post_status' => 'publish');
$rand_posts = get_posts( $args );foreach( $rand_posts as $post ) : ?>			
			
            <div>
                <div style="" class="time-axis-title">
<img src="<?php bloginfo('template_directory'); ?>/assets/img/dot@2x.png">
<span><?php the_time('Y年m月'); ?></span>
                </div>
                <div style="" class="time-axis-content">
                    <div class="child">

<?php echo mb_strimwidth(strip_tags(apply_filters('the_content', $post->post_content)), 0, 180,"..."); ?>

wordpress文章列表

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享