Plugin idea so simple, can not be found

FreshlyBlended

Registered Member
Joined
Oct 8, 2009
Messages
84
Reaction score
16
Looking for a Plugin that will automatically insert "nextpage" into my posts after so many words, sentences, or paragraphs maybe with a rand feature too so the length varies. This will help the autobloggers!

Looks like the plugin ajaxedwp might have this as a feature and I see someone striped out that feature as a separate plugin but the link to the code is broken :(

http://ajaxedwp.com/forum/general-support/help-with-post-pagination/

Doesn't appear to exist. Anyone else want to take a stab?
 
Last edited:
I decided to do a quick dirty hack to WP-O-Matic so I will share my code. I tested it and it works for me

Basically I added this new function below and then I modified "function insertPost(" so that the first thing it does is pass the "$content" var to my new function so we can add the nextpage tag. I have some variables at the top of the function that you can mess with to get a certain number of words or sentences on the page. I also added in a bit of randomness to make it look more human.

I made it so it only adds one nextpage tag so the first page will look nice and the rest of the article will be on page 2 no matter how long it is.

If someone wants to make this a plugin and tie into the save post event that would be awesome This way it would not be tied into wp-o-matic and can work with any new post

PHP:
 function pagePost($content)
  {
	  $minWordsFirstPage = 350;
	  $minSentancesFirstPage = 15;
	  $sentancesFirstPageRange = 5;
	  $minWordsRequiredToPage = 650;
	  
	  $words = explode(' ', $content);
	  
	  //check to see if there are enough words in the post to determine if paging is needed
	  if( count($words) > $minWordsRequiredToPage )
	  {
		  $words = 0;
		  $sentancesToAdd = 0;
		  do {
			  	//check to see if there are enough words on the first page.
				//if not lets add some more words
				if (count($words) >= $minWordsFirstPage) {
					break;
				}
				else
				{
					//lets add a bit of simple randomization to the number of sentances on the first page
					$sentancesFirstPage = rand( $minSentancesFirstPage, $minSentancesFirstPage + $sentancesFirstPageRange);
					$sentancesFirstPage = $sentancesFirstPage + $sentancesToAdd;

					$sentances = explode('.', $content, $sentancesFirstPage);
					
					$sentancesTemp = $sentances;
					$sentancesTemp[$sentancesFirstPage] = '';
					$firstPageText = implode('.', $sentancesTemp);
					$words = explode(' ', $firstPageText);

					$sentancesToAdd = $sentancesToAdd + 5;
				}
				
			} while (0);
			
		//now lets add the nextpage tag for our page
		$sentances[$sentancesFirstPage - 2] =  $sentances[$sentancesFirstPage - 2] . '<!--nextpage-->';
		$content = implode('.', $sentances);	
	  }
	  return $content;
  }
 
try post teaser, its pretty random but not drasticaly random
 
try post teaser, its pretty random but not drasticaly random

Post teaser and limit post is for the "more" tag. My code fix is it insert a "nextpage" tag to be used on the SINGLE page. Its not a post preview or anything, completely different, but thanks anyways. :)

I searched for a long time and I dont think a plugin exists to automatically page your posts or automatically add the "nextpage" tag for you.

If someone could transform my function to a plugin I am sure many would appreciate it since this functionality doesn't exist.
 
Last edited:
Back
Top