WordPress 自定义存档页面-外加自定义类型文章

admin 2018年5月8日08:56:34评论472 views字数 1383阅读4分36秒阅读模式
摘要

存档页添加如下代码:这里我就不提供CSS样式了,因为我的主题样式和你的肯定不同的,你可以参考我的 [ 存档页面 ] F12 根据我的样式修改。

WordPress 自定义存档页面-外加自定义类型文章

存档页添加如下代码:

<?php /* template name:文章存档 description: template for https://www.xiaoxiaowu.me/ XiaoXiaoWu theme */ ?> // 这里添加你的主题页头 <?php $args = array( 'posts_per_page' => -1, 'post_type' => array( 'post','product','shuoshuo'), //根据你的主题自行修改array中的值,如果只想显示默认类型文章,这行删除 ,'product','shuoshuo' 'post_status' => 'publish', 'ignore_sticky_posts' => 1, ); $yearpost = new WP_Query( $args ); $i = 1; ?> <section class="animated bounceInLeft"> <article class="post single"> <?php if($yearpost->have_posts()) : ?> <?php while($yearpost->have_posts()) : $yearpost->the_post() ?> <?php if( $date != date( 'Y', strtotime($post->post_date) ) ){ ?> </ul> <h2 itemprop="name headline" class="fh"><?php echo date( 'Y', strtotime($post->post_date) ); ?></h2> <ul style="background: #fff;color: #9E9E9E;"> <?php }else{ ?> <?php if( $i == 1 ){ ?> <div><?php echo date( 'Y', strtotime($post->post_date) ); ?></div> <ul> <?php } ?> <?php } ?> <li id="post-<?php the_ID(); ?>"><time datetime="<?php the_time('Y-m-d h:i:s'); ?>"><?php the_time('Y-m-d'); ?></time> <span>—</span> <a href="<?php%20the_permalink();%20?>" class="gdbt" title="<?php the_title(); ?>">[ <?php the_title(); ?> ] </a></li> <?php $i++; $ul = 0; $date = date( 'Y', strtotime($post->post_date) ); endwhile; ?> <?php endif; wp_reset_query(); ?> </div> </div> //这里添加你的主题的页尾

这里我就不提供CSS样式了,因为我的主题样式和你的肯定不同的,你可以参考我的 [ 存档页面 ] F12 根据我的样式修改。

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2018年5月8日08:56:34
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   WordPress 自定义存档页面-外加自定义类型文章http://cn-sec.com/archives/50971.html

发表评论

匿名网友 填写信息