Wordpress:获取指向一页上所有帖子的链接 [英] Wordpress: Get links to all posts on one page
问题描述
我想在我的博客中添加一个页面,其中包含指向博客中所有帖子的链接.不仅是一个页面中的 10 个或其他内容,而是所有这些(如果这是一个坏主意,我很想知道为什么).
除了链接之外,每个帖子的名称和日期也很好.
应该这样做;
-1, 'orderby' => 'post_date' );$postslist = get_posts( $args );foreach ($postslist as $post) : setup_postdata($post);?><div><a href="<?php the_permalink(); ?>"><?php the_title();?></a><br/><?php the_date();?><br/><?php the_excerpt();?>
<?php endforeach;?>
请注意,get_posts() 的默认orderby"参数实际上是post_date".为了清楚起见,我刚刚添加了它.在此处查看如何配置 the_date().
我同意上面关于分页的评论.如果你有很多帖子,它可能会变得笨拙.
I'd like to add to my blog a page that contains links to all the posts in the blog. Not only 10 in a page or something, but all of them (if that's a bad idea I'd be interested to know why).
Besides links, the name of each post and its date would be nice as well.
Something like this should do it;
<?php
$args = array( 'numberposts' => -1, 'orderby' => 'post_date' );
$postslist = get_posts( $args );
foreach ($postslist as $post) : setup_postdata($post); ?>
<div>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<br />
<?php the_date(); ?>
<br />
<?php the_excerpt(); ?>
</div>
<?php endforeach; ?>
Note that the default 'orderby' parameter for get_posts() is actually 'post_date'. I've just added it in for clarity. Have a look here for how to configure the_date().
I agree, with the comment above about pagination. If you have a lot of posts, it might become unwieldy.
这篇关于Wordpress:获取指向一页上所有帖子的链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!