我加的太单一了。php菜单:
<ul id="nav">
<?php
$all_posts = get_posts(array(
));
// this variable will contain all the posts in a associative array
// with three levels, for every year, month and posts.
$ordered_posts = array();
foreach ($all_posts as $single) {
$year = mysql2date(\'Y\', $single->post_date);
$month = mysql2date(\'F\', $single->post_date);
// specifies the position of the current post
$ordered_posts[$year][$month][] = $single;
}
// iterates the years
foreach ($ordered_posts as $year => $months) { ?>
<li>
<?php echo $year ?>
<ul class="active">
<?php foreach ($months as $month => $posts ) { // iterates the moths ?>
<?php foreach ($posts as $single ) { // iterates the posts ?>
<li>
<a href="<?php echo get_permalink($single->ID);// echo \'#post-\'.$single->ID;?>"><?php echo get_the_title($single->ID); ?></a></li>
</li>
<?php } // ends foreach $posts ?>
<?php } // ends foreach for $months ?>
</ul>
</li> <?php
} // ends foreach for $ordered_posts
?>
</ul>
在此代码之后,将有一个get循环来打印单个帖子:
<div id="content" class="site-content" role="main">
<?php /* The loop */ ?>
<?php rewind_posts(); ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( \'content\', get_post_format() ); ?>
<?php twentythirteen_post_nav(); ?>
<?php comments_template(); ?>
<?php endwhile; ?>
</div><!-- #content -->
但在每一页上,我都有最新的帖子。
请帮帮我。