0

I've defined a custom post type called Fishing Reports, and want to break it down by states, then regions.

For example: url.com/fishing-reports/florida/northwest/

That part is working as expected. However, there will be hundreds of posts pulled in from another custom post type, so it will need to support paging.

My issue is that the paging urls (/page/2/, /page/3/, etc) are redirecting back to the parent post.

So this: url.com/fishing-reports/florida/northwest/page/2/

Keeps redirecting to url.com/fishing-reports/florida/northwest/

It also happens with top level pages:

url.com/fishing-reports/florida/page/2/ redirects to -> url.com/fishing-reports/florida/

Here's the query I'm running on the page (just hardcoded at the moment). Note, when I put the same query into a default WP Page, everything works as expected:

<?php if ( have_posts() ) : // Overall post loop ?>
<?php while ( have_posts() ) : the_post(); ?>
<h1>
    Fishing Reports
    <?php the_title(); ?>
    <?php the_field('state'); ?>
    <?php the_field('fl_county'); ?></h1>
<?php the_content(); ?>
<?php endwhile; ?>
<?php endif; ?>

<?php wp_reset_postdata(); ?>

<?php 
  // Secondary query for another post type in the system
  $latest_args = array(
                'post_type'      => 't3',
                'posts_per_page' => 5, 
                'meta_query' => array(
                    'relation' => 'OR',
                        array(
                            'key'     => 'fl_county',
                            'value'   => 'Escambia',
                            'compare' => '=',
                        ),
                        array(
                            'key'     => 'fl_county',
                            'value'   => 'Santa Rosa',
                            'compare' => '=',
                        ),
                        array(
                            'key'     => 'fl_county',
                            'value'   => 'Okaloosa',
                            'compare' => '=',
                        ),
                        array(
                            'key'     => 'fl_county',
                            'value'   => 'Walton',
                                'compare' => '=',
                            ),
                            array(
                                'key'     => 'fl_county',
                                'value'   => 'Bay',
                                'compare' => '=',
                            ),
                            array(
                                'key'     => 'fl_county',
                                'value'   => 'Gulf',
                                'compare' => '=',
                            ),
                            array(
                                'key'     => 'fl_county',
                                'value'   => 'Franklin',
                                'compare' => '=',
                            ),
                            array(
                                'key'     => 'fl_county',
                                'value'   => 'Wakulla',
                                'compare' => '=',
                            ),
                            array(
                                'key'     => 'fl_county',
                                'value'   => 'Jefferson',
                                'compare' => '=',
                            ),
                            array(
                                'key'     => 'fl_county',
                                'value'   => 'Taylor',
                                'compare' => '=',
                            ),
                            array(
                                'key'     => 'fl_county',
                                'value'   => 'Dixie',
                                'compare' => '=',
                            ),
                            array(
                                'key'     => 'fl_county',
                                'value'   => 'Levy',
                                'compare' => '=',
                            ),
                        ),   
                );

        $latest_args['paged'] = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;

        $latest_query = new WP_Query($latest_args);

        if($latest_query->have_posts()): ?>
           <?php while($latest_query->have_posts()):$latest_query->the_post(); ?>
             <?php get_template_part('strongcatch'); ?>
           <?php endwhile; ?>
        <?php endif;
        wp_reset_postdata(); 
        get_template_part( 'nav', 'below' );
        ?>

Here's what the Monkeyman Rewrite Analyzer shows:

Monkeyman Rewrite Analyzer

Here's my full fishing report CPT configuration: CPT Config

  • The URL you say is not working doesn't match the URL you have in the rewrite analyzer. Are you doing any sort of query in the template? – Milo Oct 15 '15 at 15:53
  • Updating the question. It's the same result for parent pages and child/grandchild pages. Ex: /fishing-reports/florida/page/2/ redirects to /fishing-reports/florida/, and /fishing-reports/florida/northwest/page/2/ redirects to /fishing-reports/florida/northwest/ – Chris Fletcher Oct 15 '15 at 17:00
  • So florida is a post in your custom post type? What is page/2/ supposed to show? That pagination format is for post type archives, not single posts. – Milo Oct 15 '15 at 17:26
  • The fishing reports CPT is essentially just a page where we'll define which individual reports should show up. The individual reports come from the t3 CPT. It's similar to having a Page in WordPress that loops through Posts that match a certain criteria. Since it's looping through an unknown quantity, it needs to support paging, but for some reason my setup is stripping out the paging stuff and just redirecting to the original page. But if I use a plain-ol' WP page, it all works fine. – Chris Fletcher Oct 15 '15 at 17:34
  • I appreciate the help, by the way. This one's got me stumped :P – Chris Fletcher Oct 15 '15 at 17:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.