I have the following CPT and Taxonomy in my WP:
CPT: magazine
- Hierarchical: true
- Has Archive: true
Custom Taxonomy: authorname (Magazine Author. Not the same as WP Author)
- Attached to: CPT magazine
Custom Taxonomy: magazinename (name of the magazine)
- Attached to: CPT magazine
URL structure:
- hxxp://domain.zzz/magazine/author-name/magazine-name/magazine-page
How do I do the following:
If I go to hxxp://domain.zzz/magazine/author-name/ only the parent pages of that author are listed? (featured images of that page needs to be displayed)
If I go to hxxp://domain.zzz/magazine/author-name/magazine-name/ only the first page is displayed, along with a listing (navigation) of other pages + current page belonging to both those taxonomies?
If I go to hxxp://domain.zzz/magazine/author-name/magazine-name/magazine-page/ only that page is displayed with a listing of other pages belonging to both taxonomies?
What .php files do I need to create in the theme folder, and how will the queries look in this files?
Thanks in advance for any answers.
Kr,
Andy
EDIT:
I have following code in single-magazine.php:
<?php get_header(); ?>
<?php
$query = new WP_Query( array( 'post_type' => 'magazine') );
while ( have_posts() ) : the_post(); ?>
<div class="entry magazine">
<?php the_content(); ?>
</div>
<?php endwhile; // end of the loop. ?>
<div class="navigation">
<p>nav single-magazine.php</p>
</div>
<?php get_footer(); ?>
author
.author
is a reserved name and query variable in Wordpress.pre_get_posts
to adjust your query. Templates are quite simple, all you need is a unique template name outside of hierarchy, thetemplate_include
filter, and the default loop, nothing special here