I’m trying to create a set of WP pages with indices to all posts which have tag X as well as category Y.
I found this which seems to do exactly what I want and I understand how to edit it for each index page, but I don’t know where/how to use the actual code to create the index pages.
global $wp_query;
$args = array(
'category__and' => 'category',
'tag__in' => 'post_tag', //must use tag id for this field
'posts_per_page' => -1); //get all posts
$posts = get_posts($args);
foreach ($posts as $post) :
//do stuff
endforeach;
TIA for your help.
This is what finally worked – note that I needed the category ID but the tag slug.
You use that code to replace the basic query in the loop in your template.