如何通过自定义术语元和分类法获取术语或如何筛选tax_query
改为按术语metaslug
/id
?
function custom_pre_get_posts($query)
{
global $wp_query;
if ( !is_admin() && is_shop() && $query->is_main_query() && is_post_type_archive( "product" ))
{
$term = ???get_term_by_meta_and_taxonomy???(\'custom_meta_term\',\'my_taxonomy\');
$t_id = $term[\'term_id\'];
$tax_query = array
(
array
(
\'taxonomy\' => \'my_taxoomy\',
\'field\' => \'id\',
\'terms\' => $t_id
)
);
$query->set( \'tax_query\', $tax_query );
}
}
add_action( \'pre_get_posts\', \'custom_pre_get_posts\' );