[wp-trac] [WordPress Trac] #15551: Custom post type pagination redirect

WordPress Trac noreply at wordpress.org
Fri Nov 11 03:44:27 UTC 2016


#15551: Custom post type pagination redirect
--------------------------+-----------------------------
 Reporter:  cbsad         |       Owner:
     Type:  defect (bug)  |      Status:  reopened
 Priority:  normal        |   Milestone:  Future Release
Component:  Query         |     Version:  3.1
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+-----------------------------
Changes (by yuranikolaev):

 * keywords:  needs-patch needs-unit-tests =>


Comment:

 Can someone explain, how to make it work with an array of post types?
 For example, we got a few post types - band, person, release, cinema,
 place etc...

 I tried this one

 {{{#!php
 <?php
 function fix_request_redirect( $request ) {

         if ( isset( $request->query_vars['post_type'] )
              && 'place' === $request->query_vars['post_type'] OR 'org' ===
 $request->query_vars['post_type'] OR 'label' ===
 $request->query_vars['post_type'] OR 'band' ===
 $request->query_vars['post_type'] OR 'person' ===
 $request->query_vars['post_type'] OR 'company' ===
 $request->query_vars['post_type'] OR 'fest' ===
 $request->query_vars['post_type'] OR 'release' ===
 $request->query_vars['post_type']
              && true === $request->is_singular
              && - 1 == $request->current_post
              && true === $request->is_paged
         ) {
                 add_filter( 'redirect_canonical', '__return_false' );
         }

         return $request;
 }

 add_action( 'parse_query', 'fix_request_redirect' );
 }}}

 and it works!
 But it also make errors in php logs, and, I think, not so perfect

 I also playing with arrays, but cannot figure how to make it work properly

 Is it possible at all?

 Thanks in advance

--
Ticket URL: <https://core.trac.wordpress.org/ticket/15551#comment:19>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list