I want write function which add to my post content <!--nextpage--> tags, I write this function:
<?php
function output($content) {
$output = $content.'<!--nextpage-->'.$content;
return $output;
}
add_filter('the_content','output');
?>
Function add <!--nextpage--> tags, but this tags not works when I display posts, it are like html comments, maybe are some solution to solve this problem ?
Maybe I must use not the_content but wp_insert_post_data ?
The conversion from text with
<!--nextpage-->into “pages” happens insetup_postdata. But the hook you use executes when the template tag with the same name,the_contentis called. So what this means is you have to change the content before the loop starts. It can be a bit tricky. Off the top of my head I don’t know of any suitable hooks but you can check the source code forsetup_postdataand there might be one. In the theme, though, you can access$postsso if you put this in a template, it should work:If you don’t have PHP version => 5.3 you can’t use anonymous functions. In that case, this version will work: