阿里云服务器

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文章列表

相关阅读:
  • wordpress编辑框不让span过滤的方法
  • wordpress搜索为空时仍然返回结果问题
  • wordpress注册页取消邮箱的方法
  • wordpress用户头像在线调用代码
  • wordpress自动隐藏email注册,直接用户名密码注册
  • wordpress设置游客只能访问指定页面的方法
  • wordpress列表分页显示404页面的解决办法
  • wordpress页面默认排序修改的方法
  • wordpress新版本5.4 “Adderley” 发布上线,更新多项功能
  • wordpress默认编辑器功能增加的方法