@Howdy\\u McGee–感谢您为我指明了正确的方向。下面是我使用的代码。顺便说一下,我知道FacetWP插件在查询方面可能有点特殊。如果有人想知道,这是可行的。
function set_posts_per_page_for_attorneys_cpt( $atty ) {
if ( !is_admin() && $atty->is_main_query() && is_post_type_archive( \'attorneys\' ) ) {
$meta_query = array(array(
\'key\'=>\'last_name\',
));
$meta_query = $atty->get(\'meta_query\');
//filter out people without a particular key
$meta_query = array(array(
\'key\'=>\'title_group\',
\'value\'=>\'\',
\'compare\'=>\'!=\',
));
//update the query
$atty->set( \'orderby\', $meta_key);
$atty->set( \'order\', \'ASC\' );
$atty->set( \'meta_query\',$meta_query );
$atty->set( \'posts_per_page\', \'-1\' );
$atty->set( \'facetwp\', true);
}
}
add_action( \'pre_get_posts\', \'set_posts_per_page_for_attorneys_cpt\' );