2 Detailed the question
source | link

I have two custom post types: books and authors. Both of them have attached a custom taxonomy - genres.

How would I display the books in the fiction genre? What

What would be the URL used and the name of the template?

I can think of two methods to do this, but they have disadvantages, so I'm looking for a method that that would be similar with WP template hierarchy: visiting site.com/genre/fiction/ would call this template taxonomy-genre.php


Method 1: using custom page templates I would create a custom page template, cpt-genre.php. Then, I would create an empty page for each genre in books, using slugs like books-fiction and so on. In the URL usedtemplate, I'd read the slug of the page, interpret it and query to get the namebooks in fiction genre.
Result: accessing site.com/books-fiction would get to cpt-genre.php, and the template would display the data based on the slug of the page.
Downside: difficult to administer


Method 2: add a query string to the the taxonomy URL, read it in taxonomy-books.php and taxonomy-authors.php and modify WP_Query to display only the books / authors in the mentioned genre.
Result: accessing site.com/books/?genre=fiction would get to taxonomy-books.php, and the template would display the data based on the query string.
Downside: the URL is not clean and, also, it's not SEO friendly


So, any other ideas for new methods or, at least, for ways to mitigate the downsides of the above methods? 

I have two custom post types: books and authors. Both of them have attached a custom taxonomy - genres.

How would I display the books in the fiction genre? What would be the URL used and the name of the template?

I have two custom post types: books and authors. Both of them have attached a custom taxonomy - genres.

How would I display the books in the fiction genre?

What would be the URL used and the name of the template?

I can think of two methods to do this, but they have disadvantages, so I'm looking for a method that that would be similar with WP template hierarchy: visiting site.com/genre/fiction/ would call this template taxonomy-genre.php


Method 1: using custom page templates I would create a custom page template, cpt-genre.php. Then, I would create an empty page for each genre in books, using slugs like books-fiction and so on. In the template, I'd read the slug of the page, interpret it and query to get the books in fiction genre.
Result: accessing site.com/books-fiction would get to cpt-genre.php, and the template would display the data based on the slug of the page.
Downside: difficult to administer


Method 2: add a query string to the the taxonomy URL, read it in taxonomy-books.php and taxonomy-authors.php and modify WP_Query to display only the books / authors in the mentioned genre.
Result: accessing site.com/books/?genre=fiction would get to taxonomy-books.php, and the template would display the data based on the query string.
Downside: the URL is not clean and, also, it's not SEO friendly


So, any other ideas for new methods or, at least, for ways to mitigate the downsides of the above methods? 

1
source | link

Single taxonomy for different custom post types

I have two custom post types: books and authors. Both of them have attached a custom taxonomy - genres.

How would I display the books in the fiction genre? What would be the URL used and the name of the template?