Adding <!–nextpage–> dynamically to WordPress post

Basically, I’m trying to add the tag <!--nextpage--> to generate the pagination of the post dynamically using some shortcode in a plugin,

I’ve tried to use the following code to do such functionality.

Read More
public function __construct() {
    add_shortcode('CONTINUED', array(&$this, 'continued_handle'));
}

public function continued_handle() {
    global $post;
    add_filter('the_content', array(&$this, 'your_post_split'));
    return $this->your_post_split($post);
}

public function your_post_split($content) { 
    $output = '<div>In page 1</div>';
    $output .= '<!--nextpage-->';
    $output .= '<div>In page 2</div>';
    return $output;
}

When I use the shortcode [CONTINUED] on a page, I want it to echo <div>In page 1</div> then process the <!--nextpage--> like it normally would in WordPress and start the pagination.

What it’s actually doing is returning this in the post

<div>In page 1</div><!--nextpage--><div>In page 2</div>

It’s not actually doing the functionality of <!--nextpage--> in which I want it to

Related posts

Leave a Reply