[wp-trac] [WordPress Trac] #15551: Custom post type pagination redirect
WordPress Trac
noreply at wordpress.org
Tue Jun 21 23:03:53 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: needs-patch needs-unit-tests | Focuses:
------------------------------------------+-----------------------------
Comment (by moonomo):
In the single post for custom post type I had to show some extra data that
requires pagination. WordPress redirects any sub-page requests to the
single page (WordPress 4.5.3). Following code (taken from previous
comment, and updated a little) removes the redirection, and pagination
finally works:
{{{#!php
<?php
function fix_request_redirect( $request ) {
if ( isset( $request->query_vars['post_type'] )
&& 'custom_type' === $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' );
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/15551#comment:18>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list