junichi
junichi copied to clipboard
归档页面有小问题
如图,最后有一个
你把page-archives.php第20行 if ($mon != $mon_tmp && $mon > 0) $output .= '';
改成 if ($mon != $mon_tmp && $mon > 0) $output .= '';
试试,看你博客,是那条记录给排除在ul外面导致的,我使用过程中未发现过这个问题。
当前版本主题的page-archives.php
中归档逻辑有一点问题。
Bug复现
当并列的两篇文章拥有不同的年份、相同的月份时,Bug复现,不同年月的两篇文章归档在同一栏目下。
如图:
解决
@tlerbao 请将page-archives.php
文件替换为以下代码:
<?php
/**
* archives
*
* @package custom
*/
$this->need('header.php'); ?>
<div class="mid-col">
<div class="mid-col-container">
<article class="post post-archives">
<h1 class="title"><?php $this->title() ?></h1>
<div class="entry-content">
<?php $this->widget('Widget_Contents_Post_Recent', 'pageSize=10000')->to($archives);
$year=0; $mon=0; $i=0; $j=0;
while($archives->next()):
$year_tmp = date('Y',$archives->created);
$mon_tmp = date('m',$archives->created);
$y=$year; $m=$mon;
if ($mon != $mon_tmp && $mon > 0) $output .= '</ul>';
if ($year != $year_tmp && $year > 0) $output .= '</ul>';
if ($year != $year_tmp) {
$year = $year_tmp;
}
if ($mon != $mon_tmp || ($mon == $mon_tmp && $y != $year_tmp)) {
$mon = $mon_tmp;
$output .= '<h3>'. $year_tmp .' 年'. $mon_tmp .' 月</h3>';
$output .= '<ul>';
}
$output .= '<li><a href="'.$archives->permalink .'">'. $archives->title .'</a> ('.date('M j, Y',$archives->created).')</li>';
endwhile;
$output .= '</ul>';
echo $output;
?>
</div>
</article>
</div>
<?php $this->need('footer.php'); ?>
@FaithPatrick 感谢提供的帮助,一会儿更新。