How To Improve Dull WordPress Pagination


To add a page break to posts just add <!–nextpage–> wherever you want the break to occur. That’s it!

Now, to add the funky boxes add the following lines of code to your functions.php file:

<?php function link_pages_without_spaces() {
ob_start();
link_pages('<p class="pagelinks"><strong>Continue Reading This Post:</strong>', '</p>', 'number', '', '', '%', '');
$text = ob_get_contents();
ob_end_clean();
$text = str_replace(' <a href', '<a href', $text);
$text = str_replace('> ', '>', $text);
echo $text;
}
?>

And then add the following to your stylesheet:

.pagelinks { clear: both; margin: 2.5em 0; font-size: 1.0em; font-weight: bold; }
.pagelinks strong { color: #333333; margin: 0 0.6em 0 0; border: 1px solid #e5e5e5; padding: 0.3em 0.6em; }
.pagelinks a { margin: 0 0.8em; border: 1px solid; padding: 0.3em 0.6em; }

And finally, then add the following line to your single.php file wherever you want the boxes to appear:

<?php link_pages_without_spaces(); ?>

That’s got to be one of the quickest posts I’ve ever written!

Bookmark & Share

Related Posts

About the Author

author photo

Everton is based in London and has worked in the internet and mobile space for over ten years now, and before that worked in corporate strategy and consulting. He has a degree in Economics from Cambridge University, and currently runs the Portal and online operations for one of the largest ISPs in the UK. He also writes for Windows 7 News.

See All Posts by This Author

There Is 1 Response So Far. »

  1. #1

    Nicely done! I’m not very PHP savvy… would it be this simple to add paginated navigation to index.php or are you hacking into something WP is already doing for single pages?

Subscribe without commenting

Post a Response


Comment Policy: Any comments are permitted only because the site owner is letting you post, and any comments could be removed for any reason at the absolute discretion of the site owner.