I am trying to preview my blog post that has <!--nextpage-->
but clicking on any of the other pages just brings back to the home page.
There was an old thread that never got resolved 4 years ago https://wordpress.org/support/topic/nextpage-doesnt-work-on-preview?replies=3
The URL when I do a preview looks like this
https://www.trajano.net/?p=1569&preview_id=1569&preview_nonce=c1ab9c2efc&post_format=standard&_thumbnail_id=-1&preview=true
All well and good, but once I click on a page this happens:
https://www.trajano.net/?p=1569%2F2%2F&preview_id=1569&preview_nonce=c1ab9c2efc&preview=true
Note that the page number gets injected after ?p=1569
like ?p=1569/2/&preview...
if it was decoded.
There’s a bug regarding content pagination links not working when previewing scheduled posts or pages.
See ticket #32295
There’s already a proposed patch that adds the missing future
status check within the _wp_link_page()
helper function, that generates the content pagination links.
We could e.g. construct a quick-fix like:
add_filter( 'preview_post_link', function( $link, $post )
{
if( ! is_admin() && is_preview() && 'future' === get_post_status( $post ) )
$link = preg_replace( '~p=(\d+)%2F(\d+)%2F~', 'p=$1&page=$2', $link );
return $link;
}, 10, 2 );
or use the wp_link_pages_link
filter:
add_filter( 'wp_link_pages_link', function( $link, $i )
{
if( $i > 1 && 'future' === get_post_status( get_the_ID() ) && is_preview() )
$link = preg_replace( '~p=(\d+)%2F(\d+)%2F~', 'p=$1&page=$2', $link );
return $link;
}, 10, 2 );