Split Your Long WordPress Posts And Pages

in WordPress Tutorials

There have been a lot of discussions over the last few years about how long a blog post should be. In my experience there is no right or wrong answer. I’ve seen some of my articles that took days to write get little or no comments whilst other short news type posts that only took me 10 minutes to write got 10 times as much traffic.

Not all long articles are created equal i.e. there is no need to babble on and use 2,000 words to say something that could be said in 500. I do however believe that longer in-depth articles tend to be more useful to visitors so are more likely to be voted in social media websites and linked from other websites (therefore increasing their SEO rankings).

Some articles can be too long for readers though; either because there is too much content for the reader to digest or if the article has too many images (e.g. high loading times). If you feel that the article you are writing is too long you have two options. One option is to split the article into a series of posts (part 1, part 2 etc), thereby giving visitors a reason to subscribe and return to your site the following day or week.

Another option is to use the nextpage option in WordPress to split your article into two or more pages. By inserting <!–nextpage–> code directly into your article you can divide it into separate pages.

Those of you who have been using WordPress for years will remember that there used to be a nextpage button in the post editor but it was removed to reduce the clutter on the quicktag bar (should you wish, you can add the button back using the Easy Multiple Pages plugin). If you have added the above code into one of your posts or pages, you should not see any content after it. You should see some navigation links to your second page but don’t worry if that’s there. To show the page navigation links you need to call the wp_link_pages function in your single.php (or page.php) template. Most themes don’t have this function so you may need to insert it yourself.

All you have to do is enter the following code:

<?php wp_link_pages(); ?>

directly after:

<?php the_content() ; ?>

Once you have added the code to your template, you should see navigation links e.g. Page 1, Page 2, Page 3 etc. The links can be styled easily by simply entering some parameters in the function call. The default parameters are:

<?php $args = array(
    'before'           => '<p>' . __('Pages:'),
    'after'            => '</p>',
    'link_before'      => ,
    'link_after'       => ,
    'next_or_number'   => 'number',
    'nextpagelink'     => __('Next page'),
    'previouspagelink' => __('Previous page'),
    'pagelink'         => '%',
    'more_file'        => ,
    'echo'             => 1 ); ?>

You could also wrap the function with a CSS division and style the links from your stylesheet.

I personally prefer not to use the wp link pages function as you can only add it directly above or below your content. Instead, I link to pages directly within the post by creating my own navigation menu within the post. If you have customised your permalinks (i.e. you’re not using the default http://www.yoursite.com/?p=123) then additional pages simply have a number appended to them. For example:

  • Page 1 would be your regular permalink e.g. http://www.yoursite.com/test-post/
  • Page 2 would be http://www.yoursite.com/test-post/2/
  • Page 3 would be http://www.yoursite.com/test-post/3/
  • ….and so on.

As you can see, it’s easy to create your own little sub menu within your article by linking directly to each page. Entering links manually within posts gives you more control over how your navigation links are styled on different posts though if you split posts up regularly you may want to use the wp link pages function so that your post menus are consistent throughout your site.

If you are looking to split up your longer articles into pages, I recommend reading more at the links noted below. If you are unsure of any aspect of this please let me know :)


Link: Styling Page-Links | wp link pages

Comments (6)

  • Comment by Bnimbhal


    Currently I am using apptheme theme and the pagination is not available, I followed your procedure and its working now, but I want to change the CSS for that as the display is very normal, can you plz explain how I can style the pagination.


  • Comment by Janmejai

    Any tut to make the Next page numbering look better,no one will pay attention to it the way it looks in default.

  • Comment by Arya

    You are the only tutor who specified where to place the <?php wp_link_pages(); ?> in the single or post php
    Unfortunately weighter work for me. For a simple function I am having a hell of a time with it. I went for a premium theme, Aspire, to avoid these things. If I only knew

  • Comment by Kevin Muldoon
    Kevin Muldoon

    I’m not aware of any myself. I think manually is a better solution though as if you define a set number of words for a cutoff, some posts will be cut off when not needed. For example, if you put a cutoff at 1,000 words, articles with 1,100 words would still have a cutoff at 1,000 words (which just isn’t practical).

  • Comment by Borris

    Do you know of a plugin that can split posts automatically?
    My blog has tons of posts. I can’t go into each post and place the code.

  • Comment by Dale

    Thanks, this is quite useful for us.