I’ve created archive pages for all my taxonomies (taxonomie-{taxonomy-name}.php
) and this works fine. The slug of my taxonomies are the same as the slug of it’s post-type
. This makes it possible to create neat hierarchy in the URL, for example:
When post-type products
has ‘type’ as a taxonomy with the values book, cd and dvd. post-type1 has the slug product
and taxonomy1 has the same slug: product
.
This way I can list the taxonomy-archives in the following way:
products/book
products/cd
products/dvd
and this works great. However: the pagination works on the products archives but on the products/{type}
archive it gives a 404.
Any clue?
Code of the taxonomy template is as follows:
<?php get_header(); ?>
<section id="inhoud" class="hfeed">
<nav class="navigatiebalk">
<ul class="pagina-navigatie">
<li class="volgende-pagina"><?php previous_posts_link(''); ?></li>
<li class="vorige-pagina"><?php next_posts_link(''); ?></li>
</ul>
</nav>
<?php while ( have_posts() ) : the_post(); ?>
<?php
$post_type = get_post_type( get_the_ID() );
?>
<article class="hentry publicaties artikel <?php echo $post_type ?>">
<header class="artikel-hoofd">
<?php the_title( '<h1 class="titel"><span class="datum date">' . the_date('d.m.y', '', '', false) . '</span><a href="' . get_permalink() . '" title="' . the_title_attribute( 'echo=0' ) . '" rel="bookmark">', '</a></h1>' ); ?>
<figure class="icoontje"></figure>
</header>
<section class="inleiding">
<figure class="bericht-icoon"><?php $large_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large'); echo '<a href="' . $large_image_url[0] . '" class="thumbnail-link colorbox" rel="lightbox" title="' . the_title_attribute('echo=0') . '" >'; the_post_thumbnail('thumbnail', array('class' => 'artikel-thumbnail')); ?></a>
</figure>
<span><?php $this_excerpt = get_the_excerpt(); echo $this_excerpt; ?>... <a href="<?php the_permalink(); ?>" class="lees-verder">Lees en luister</a>
</span>
</section>
</article>
<?php endwhile; ?>
<nav class="navigatiebalk">
<ul class="pagina-navigatie">
<li class="volgende-pagina"><?php previous_posts_link(''); ?></li>
<li class="vorige-pagina"><?php next_posts_link(''); ?></li>
</ul>
</nav>
</section>
<?php get_footer(); ?>
Figured it out myself. Apparently, the pagination break because both my ‘products’ and my ‘types’ (those are not the terms I have, just for demonstration purposes) are having the same slug. Products has a slug of ‘products’ and types has a slug of ‘products/%typename%’. Due to this I can make my permalinks hierarchical: products/dvd or products/cd. It worked, although, it broke both my pagination on taxonomy archive-pages as it broke my permalinks to individual post-types. What I did was the following to fix it:
I added some mod-rewrite rules so apache will find the paginated taxonomy archive and the individual archive-post.
If I am understanding you correctly, then you have a taxonomy named “type” defined on your site. This will break all sorts of things. “Type” is one of the reserved terms and should not be used for taxonomies.