and previews

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

Leave a Comment