You can try to use the the_post
filter, to override the content pagination, that takes place within the setup_postdata()
function ( PHP 5.4+ ):
/**
* Ignore the <!--nextpage--> for content pagination.
*
* @see http://wordpress.stackexchange.com/a/183587/26350
*/
add_action( 'the_post', function( $post )
{
if ( false !== strpos( $post->post_content, '<!--nextpage-->' ) )
{
// Reset the global $pages:
$GLOBALS['pages'] = [ $post->post_content ];
// Reset the global $numpages:
$GLOBALS['numpages'] = 0;
// Reset the global $multipage:
$GLOBALS['multipage'] = false;
}
}, 99 );
to ignore the <!--nextpage-->
feature.
The global $pages
variable contains the paginated content:
$pages = explode('<!--nextpage-->', $content);
so that’s why we need to restore it to:
$pages = array( $post->post_content );
We actually don’t need to restore the $numpages
variable, but we do it as part of the house cleaning. If we only restored $pages
and $numpages=0
then we would get:
<div class="page-links">Pages:</div>
The wp_link_pages()
function checks if the global $multipage
is true to display the content pagination output. So that’s the variable to set to false to remove the whole output. We could also use the wp_link_pages
filter to remove it.