Taxonomy Pagination second page – 404 not found
-
I’m having problems with taxonomy pagination, I’m really stressed up.
So I remade my taxonomy template over and over again…
I just can’t figure it out way am I doing wrong!
Any suggestion/help will be appreciated…I have:
post_type = ‘custom-post-type’
taxonomy = ‘custom-taxonomy’
custom-taxonomy = ‘custom-term-01’, ‘custom-term-02’ etc.
Custom Post Type Page = custom page template with posts by post_type => ‘custom-post-type’Problem:
The pagination only works when I get posts by post_type on Custom Post Type Page -> https://www.example.com/custom_post_type_page), the problem is with the template custom-taxonomy => taxonomy-{custom-taxonomy}.php
I can get the firsts post of ‘custom-term-01’ -> https://www.example.com/custom-taxonomy/custom-term-01 but only the first ones or all of them. If I go to the next page => https://www.example.com/custom-taxonomy/custom-term-01/page/2 it goes to index.php ( and not to taxonomy-{custom-taxonomy}.php like should be…
I’m using permalinks /%postname%/…
So taxonomy-{custom-taxonomy}.php it would be something like this:
<?php
$paged = (get_query_var(‘page’)) ? get_query_var(‘page’) : 1; // current page
$term = get_term_by( ‘slug’, get_query_var( ‘term’ ), get_query_var( ‘taxonomy’ ) ); // current term
?><!– ARGS –>
<?php
global $query_string;
$args = wp_parse_args($query_string); // to not overwrite all the original page code (the $query_string)$args = array(
‘post_type’ => ‘custom-post-type’,
‘posts_per_page’ => ’10’,
‘paged’ => $paged,
‘tax_query’ => array(
array(
‘taxonomy’ => ‘custom-taxonomy’,
‘field’ => ‘slug’,
‘terms’ => $term->slug
)
)
);
?><!– WP QUERY –>
<?php $wp_query = new WP_Query( $args ); ?>
<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?><!– THE POST –>
<?php endwhile; ?>
<!– NAVIGATION –>
<?php if($wp_query->max_num_pages>1) : ?>
<!– PAGINATION PLUGIN –>
<?php endif; ?><!– RESET QUERY –>
<?php wp_reset_query(); ?>
- The topic ‘Taxonomy Pagination second page – 404 not found’ is closed to new replies.