我在函数中添加了以下内容。php文件及其工作原理:
function toolset_fix_custom_posts_per_page( $query_string ){
if( is_admin() || ! is_array( $query_string ) )
return $query_string;
$post_types_to_fix = array(
array(
\'post_type\' => \'news_article\',
\'posts_per_page\' => 6
),
// add another if you want
/*
array(
\'post_type\' => \'movie\',
\'posts_per_page\' => 2
),
*/
);
foreach( $post_types_to_fix as $fix ) {
if( array_key_exists( \'post_type\', $query_string )
&& $query_string[\'post_type\'] == $fix[\'post_type\']
) {
$query_string[\'posts_per_page\'] = $fix[\'posts_per_page\'];
return $query_string;
}
}
return $query_string;
}
添加\\u筛选器(\'请求\',\'工具集\\u修复\\u自定义\\u每页帖子\');