How to use pagination in wordpress post without plugin

There is difference between post pagination and in post pagination.If you want to keep pagination in wordpress post without plugin, Than use our code

When we are developing the new wordpress theme then we need to always need to think about post pagination and in post pagination. Yes, there is difference between post pagination and in post pagination.

How to use pagination in wordpress post without plugin

How to use pagination in wordpress post without plugin
How to use pagination in wordpress post without plugin

If you want to keep single post and pagination between in single post that is also possible through wordpress api. In this article I will show you hwo to use the in page or post pagination.

Open your single.php file from wordpress theme folder and put following code in that.

<?php wp_link_pages( ); ?>

We can pass the following parameter the this function.

<?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 ); ?>
<?php wp_link_pages( $args ); ?>

This is the one of the sample code.

<?php wp_link_pages('before=</pre>
&after=
<pre>&next_or_number=number&pagelink=page %'); ?>

Now I will explain What wordpress doing for using this function. WordPress is using simple explode php function for using the next page tag. Like following way.

$content = get_the_content();
$pages = explode('<!--<span class="hiddenSpellError" pre="" data-mce-bogus="1">nextpage</span>-->', $content);

you can also use the above code in your loop.

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

Leave a Reply

Your email address will not be published.