是的,您可以调用操作“pre\\u get\\u posts”。
add_action(\'pre_get_posts\',\'search_filter\');
您可以添加参数:
$args = array(
\'post_status\' => \'publish\',
\'posts_per_page\' => 6,
\'paged\' => $paged,
\'meta_key\' => \'event_date\',
\'orderby\' => \'meta_value_num\',
\'order\' => \'ASC\'
);
您可以使用上述参数,例如:
function search_filter($query){
if ( !is_admin() && $query->is_main_query() ) {
$query->set(\'post_status\', \'publish\');
$query->set(\'meta_key\', \'event_date\');
$query->set(\'orderby\', \'meta_value_num\');
$query->set(\'order\', \'ASC\');
}
}