我正在尝试编辑WordPress的默认帖子页面,以便它显示所有帖子,而不是最近的10篇,但我不确定要编辑哪个文件。
我试图在wp includes/post中编辑wp\\u get\\u recent\\u posts函数。php,但没有任何效果。有人能给我指出正确的方向吗?
function wp_get_recent_posts( $args = array(), $output = ARRAY_A ) {
if ( is_numeric( $args ) ) {
_deprecated_argument( __FUNCTION__, \'3.1\', __( \'Passing an integer number of posts is deprecated. Pass an array of arguments instead.\' ) );
$args = array( \'numberposts\' => absint( $args ) );
}
// Set default arguments.
$defaults = array(
\'numberposts\' => 1000, \'offset\' => 0,
\'category\' => 0, \'orderby\' => \'post_date\',
\'order\' => \'DESC\', \'include\' => \'\',
\'exclude\' => \'\', \'meta_key\' => \'\',
\'meta_value\' =>\'\', \'post_type\' => \'post\', \'post_status\' => \'draft, publish, future, pending, private\',
\'suppress_filters\' => true
);
最合适的回答,由SO网友:Krystian Kupiec 整理而成
您必须将“post\\u per\\u page”设置为“-1”。将此代码添加到您的主页或索引中。php。
WP\\U查询(推荐)
$args = array(\'posts_per_page\' => -1);
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) : $the_query->the_post();
the_title();
the_content();
endwhile;
/* Restore original Post Data */
wp_reset_postdata();
} else {
// no posts found
}
query\\u posts()方式
// Args that you pass to loop
$args = array(\'posts_per_page\' => -1);
// The Query
query_posts( $args );
// The Loop
while ( have_posts() ) : the_post();
the_title();
the_content();
endwhile;
// Reset Query
wp_reset_query();
或者,您可以转到仪表板->设置->阅读,并将每页的最大帖子数设置为“1000”或其他。