• Resolved dali88

    (@dali88)


    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(); ?>

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hey dali88, I’m having a similar problem with my custom taxonomy pagination.

    This thread says [resolved] but I didn’t see a solution here. Did you find a solution?

    If so, you should paste it here, I’d appreciate it. ??

    Thread Starter dali88

    (@dali88)

    Unfornatelly i had to find to solution by myself because nobody answered… You just need to remove the parameter “posts_per_page”, that was the problem, the taxonomy pagination only works when you are using the default posts_per_page defined in WP backoffice. And I used the kressi pagination ( https://www.kriesi.at/archives/how-to-build-a-wordpress-post-pagination-without-plugin ), but this wasn’t a problem, you can use any plugin for pagination, although I recommend the kresi pagination, is just a function that you can paste into your functions file. And don’t forget to reset the query after calling the kresi_pagination() or other plugin pagination function. Why use a plugin for everything?

    Hope this fixed your problem too.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Taxonomy Pagination second page – 404 not found’ is closed to new replies.