我正在尝试创建新闻纸网站,需要帮助才能显示最近帖子的内容和旧帖子的标题......这是我的代码
<?php
$args = array(
'orderby' => 'id',
'hide_empty' => 1,
'order' => 'ASC'
);
$categories = get_categories($args);
foreach($categories as $category) { ?>
<div class="newsdiv">
<?php
echo '<center><a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a></center> <br/> ';
$post_args = array(
'numberposts' => 3,
'category' => $category->term_id
);
$posts = get_posts($post_args);
foreach($posts as $post) {?>
<a href="<?php the_permalink(); ?>"><?php echo"*";the_title(); ?></a>
<div class="entry">
<?php the_content(); ?>
</div>
<?php
}
echo '<dd class="view-all"> <a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>Read more </a></dd>';
echo '</dl>';
?>
</div>
<?php
}
?>
答案 0 :(得分:0)
您可以尝试使用上一篇文章
<?php previous_post_link( $format, $link, $in_same_cat = false, $excluded_terms = '', $taxonomy = 'category' ); ?>
你可以用更简单和/或更复杂的方式使用它。
<?php previous_post_link(); ?>
有关更多信息,您可以使用codex http://codex.wordpress.org/Function_Reference/previous_post_link