似乎只有10篇帖子显示在作者的页面上。php文件。我用的主题就是这个。php文件:-
<?php while ( have_posts() ) : the_post(); ?>
<?php endwhile; ?>
<?php wt_pagination(); ?>
循环仅获得(作者的)前10篇帖子。如何将其更改为前30篇帖子。无需写入辅助(自定义)循环。似乎只有10篇帖子显示在作者的页面上。php文件。我用的主题就是这个。php文件:-
<?php while ( have_posts() ) : the_post(); ?>
<?php endwhile; ?>
<?php wt_pagination(); ?>
循环仅获得(作者的)前10篇帖子。如何将其更改为前30篇帖子。无需写入辅助(自定义)循环。使用循环时,将从后端的“设置”->“读取”中设置的选项中选择显示的帖子数。它影响所有的标准循环,而不仅仅是作者页面。
要仅更改作者页,必须使用pre_get_posts
使用钩子和设置想要的帖子数量posts_per_pag
e参数:
add_action(\'pre_get_posts\',\'change_numberposts_for_author\');
function change_numberposts_for_author( $query ) {
if ( ! is_admin() && $query->is_main_query() && is_author() ) {
$query->set(\'posts_per_page\', 30); // 30 is the number of posts
}
}
另请参见is_author() on Codex我有以下代码:/*Get number of entries*/ function get_entries_num( $id ) { $count= count_user_posts( $id ); if ($count == 1) { return sprintf(__(\'%s total post\',\'upme\'), $post, $count);