Many longer WordPress blog posts are split up into multi-pages. The thinking is that the page loading time will improve, the bounce rate might decrease because the user might stick around a bit longer and the marketing guys say it is a way of adding more ads. Whatever your reason the feature is pretty nifty and easy to use.

We have all seen something like the following.

Representation of what a post with split pages looks like

Representation of what a post with split pages looks like

Representation of what a post with split pages looks like

To split a post into different pages you simply add the following short code in your post there where you want the post to break.

If your theme does not make provision for this multi-pages will not work on your site. Your theme needs to call the wp_link_pages function to make this all work. This call is normally made just after the call to show the content. In my theme this call appears in /template-parts/content.php.

Everything is pretty simple up to now, no rocket science here. The only problem that could occur is when you want to style these page links. Styling the page links themselves is pretty simple to do but styling the current page and the title (Pages:) is not so simple as the wp_link_pages function does not make classes available for this type of styling. All you need do is to simply add a few arguments to the wp_link_pages call to make the required classes available.

There we go, that is all it takes, all we need do now is to actually add the styling. The following is the styling I use on this blog:

It is important to note that in this styling the order of doing things is very important as certain styles needs to override previous styles, get the order wrong and things might not work.

If you know of another or an easier way of doing this I would appreciate a heads-up in the comments. Thanks for visiting.

Write a Reply or Comment

Your email address will not be published. Required fields are marked *


*