inserting <--!pagebreak--> every 200 characters automatically

:)

I'm trying to split a post in pages at every 200 characters with !--nextpage--

I found this code on this page that actually looks pretty good (for my understanding alone - yes I'm a newbie to development):

?php
$content = get_the_content();
$strings = wordwrap($content, 500, "!--break--"); //insert this every 500 chars, but preserve whole words.
$chunks = explode("!--break--", $strings); create a new string of 500-char sections.

ob_start(); // buffer the output of the following expressions...
foreach($chunks as $chunk_content) {
    echo 'span'; // use span instead of div so as to not interrupt the paragraph formatting of the content when viewed normally (graceful degradation).
    echo $chunk_content;
    echo '/span ';
    }
$segmented_content = ob_get_contents(); // put the results of the above expressions into a variable.
ob_end_clean(); // discard the expressions that were buffered.
echo nl2br($segmented_content); // put the result through a filter which replaces line-breaks with br tags.
?

I tried to replace !--break-- by !--nextpage--, it looks like !--nextpage-- is not recognized as such in html!

How can it work?

(Yes i've tried a lot of code functions and plugins... I've already inserted wp_link_pages(); still none would work :/ )

Thanks for any help...

Topic nextpage split Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.