我知道很多人会回答如何按类别过滤标签,但我需要一些帮助。
$args = array(
'tag' => get_queried_object()->slug,
'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => 'category',
'field' => 'slug',
'terms' => 'interior',
),
)); //get all posts
$posts_new = get_posts($args);
它有效。但我需要,当像这样的url(example.com/tag/lexington/?category=interior)或(example.com/tag/lexington/category/interior)时,从该URL获取类别,然后传递给那个
array(
'taxonomy' => 'category',
'field' => 'slug',
'terms' => <my category from url>,
),
感谢您的关注。