wordpress文章列表倒叙输出

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

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

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

PHP
<?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
<?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/[email protected]"> <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文章列表

猜你喜欢

转载自www.cnblogs.com/idid/p/12421780.html