【发布时间】:2013-09-11 14:39:18
【问题描述】:
我曾经在 wordpress 中写过几篇博客文章。我已经完全更新了 10 个帖子,并且完美地显示了 10 个帖子。
我的问题是,
我只需要显示 9 个帖子。最后更新的帖子不应显示在网站上。我需要代码来排除第 10 个帖子的最新帖子。我需要将代码放在functions.php上。
谁能帮帮我。
提前致谢。
【问题讨论】:
我曾经在 wordpress 中写过几篇博客文章。我已经完全更新了 10 个帖子,并且完美地显示了 10 个帖子。
我的问题是,
我只需要显示 9 个帖子。最后更新的帖子不应显示在网站上。我需要代码来排除第 10 个帖子的最新帖子。我需要将代码放在functions.php上。
谁能帮帮我。
提前致谢。
【问题讨论】:
只需从admin pannel 转到您的settings,然后单击reading,然后将blog post at most 更改为9。
或者以编程方式你可以尝试
$latestPosts = new WP_Query( array(
'posts_per_page' => 9,
'orderby' => 'date',
'order' => 'DESC',
)); // end query
while ($latestPosts->have_posts()) : $latestPosts->the_post();
【讨论】: