新建一个archives-update.php文件,将下面代码粘贴到archives-update.php里面,然后将archives-update.php文件放到这个目录:/wp-content/themes/modown/template,最后在前端页面模板里选择文章存档-更新日志。
模板代码:
<?php /* template name: 文章存档-更新日志 description: template for mobantu.com modown theme */ get_header();?> <div class="banner-page" <?php if(_MBT('banner_page_img')){?> style="background-image: url(<?php echo _MBT('banner_page_img');?>);" <?php }?>> <div class="container"> <h1 class="archive-title"><?php the_title();?></h1> </div> </div> <div class="main"> <?php do_action("modown_main");?> <div class="container"> <div class="content-wrap"> <div class="content archives clearfix"> <?php global $post; $previous_year = $year = 0; $previous_month = $month = 0; $ul_open = false; $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $args = array( 'post_type' => 'post', 'ignore_sticky_posts' => 1, 'paged' => $paged, 'orderby' => 'modified', 'order' => 'DESC' ); query_posts($args); while ( have_posts() ) : the_post(); $year = mysql2date('Y', $post->post_modified); $month = mysql2date('n', $post->post_modified); $day = mysql2date('j', $post->post_modified); if($year != $previous_year || $month != $previous_month) : if($ul_open == true) : echo '</ul></div>'; endif; echo '<div class="item"><h3>' . get_the_modified_time('F Y') . '</h3>'; echo '<ul class="archives-list">'; $ul_open = true; endif; $previous_year = $year; $previous_month = $month; ?> <li> <time> <?php echo get_the_modified_time('j'); ?>日</time> <a href="<?php%20the_permalink();%20?>"> <?php the_title(); ?> </a> <span class="muted"> <?php comments_number('', __('1评论','mobantu'), __('%评论','mobantu')); ?> </span> </li> <?php endwhile; ?> </ul> </div> <?php MBThemes_paging();?> </div> </div> </div> <?php get_footer();?>
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。