I apologize if this is a difficult question to understand, but really it's a template hierarchy / rewrites question.
I have set up a few rewrite rules that are successful, but I'm hoping that I can manipulate them to call different template files in the hierarchy, so I can control archive pages more logically. I have a team-news custom post type, and a sport taxonomy. My goal is to have a team-news archive of posts only from a specific sport, and a separate sport archive for all posts and pages associated with that taxonomy. Unfortunately, I'm only able to access the sport taxonomy archive with my current rewrites, not the team-news CPT archive.
Here are my rewrite rules and an explanation of what I think happens:
This one brings up
taxonomy-sport.php, although I was hoping it would bring up
archive-team-news.php. I need the
sport= part, because I only want to show team-news posts for that sport.
This one rightly brings up
taxonomy-sport.php as I had hoped.
According to the Query Monitor plugin, the template hierarchy when requesting the url
/athletics/team/varsity-football/news/ is this:
- taxonomy-sport.php --- The one it's using
- archive-team-news.php --- The one I want it to be
Is there any way to make archive-team-news.php work for that URL? Would I need to filter the hierarchy? I'm pretty new to WP, so I don't want to change up too much...
EDIT 1: To simplify my goal --
?post_type=&taxonomy= will always pull up a taxonomy archive page, as far as I can tell. Can I make it pull up the post-type archive page instead?
I've changed the 2nd parameter of the first rewrite rule to
'index.php?post_type=team-news', and now the correct archive page is being displayed (
archive-team-news.php) but I still need to filter further by taxonomy somehow.
NOTE: the taxonomy slug is in the URL as
athletics/team/[taxonomy]/news/, so now I'm trying to parse the URL for that value in PHP, but I'd prefer a WP solution (less hacky).