Skip to main content
added 550 characters in body
Source Link
birgire
  • 67.8k
  • 7
  • 119
  • 251

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 numbersoutput. 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.

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 wp_link_pages() function checks if the global $multipage is true to display the content pagination numbers.

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.

deleted 2 characters in body
Source Link
birgire
  • 67.8k
  • 7
  • 119
  • 251

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 wp_link_pages() function checks if the global $multipage is true to display the content pagination numbers.

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.

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 wp_link_pages() function checks if the global $multipage is true to display the content pagination numbers.

added 10 characters in body
Source Link
birgire
  • 67.8k
  • 7
  • 119
  • 251

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 ];
        
        // Let's emptyReset the linkglobal pagination$numpages:
        add_filter($GLOBALS['numpages'] 'wp_link_pages',= 'wpse_empty_link_pages',0;

 10, 2 );
    }
// Reset the global $multipage:
}, 99 );

function wpse_empty_link_pages( $output, $args )
{
  $GLOBALS['multipage'] = remove_filter(false;

 current_filter(), __FUNCTION__ );
 }
   return '';
}, 99 );

to ignore the <!--nextpage--> feature.

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 ];
        // Let's empty the link pagination:
        add_filter( 'wp_link_pages', 'wpse_empty_link_pages', 10, 2 );
    }
    
}, 99 );

function wpse_empty_link_pages( $output, $args )
{
    remove_filter( current_filter(), __FUNCTION__ );
    return '';
}

to ignore the <!--nextpage--> feature.

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.

added 10 characters in body
Source Link
birgire
  • 67.8k
  • 7
  • 119
  • 251
Loading
Source Link
birgire
  • 67.8k
  • 7
  • 119
  • 251
Loading