How to remove Nextpage tag inside posts text depending of utm_campaign

You can use the_post hook to remove <!--nextpage-->. In this case:

add_action( 'the_post', 'campaign_remove_nextpage', 99);

function campaign_remove_nextpage ( $post ) {
    if ( ($_GET['utm_campaign']== 'nonextpagecampaign') && (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;
    }
};

Read more about this issue

More in general, you may want to read this warning about SEO effects of using <!--nextpage-->.

Leave a Comment