Skip to main content
4 of 4
deleted 2 characters in body
Dejo Dekic
  • 909
  • 1
  • 11
  • 28

Ok buddy add this code to your functions.php

//This function is responsible for splitting posts and pages using <!--nexpage-->
function my_link_pages() {
$paged_page_nav = wp_link_pages(
            array(
            'before' => '<div class="page-navigation"><ul><li class="pages">' . esc_html__( 'Pages:', 'domain' ) . '</li>',
            'after' => '</ul></div>',
            'link_before' => '<span>',
            'link_after' => '</span>',
            'echo' => false
            )
         );

//Add "current" and "page_divide" classes to our links
//READ: http://wordpress.stackexchange.com/questions/17421/wp-link-page-wrap-current-page-element
// Now let's wrap the nav inside <li>-elements
$current_class = 'current';
$classes = 'page_divide';
$paged_page_nav = str_replace( '<a', '<li class="'. $classes .'"><a' ,$paged_page_nav );
$paged_page_nav = str_replace( '</span></a>', '</a></li>', $paged_page_nav );
$paged_page_nav = str_replace( '"><span>', '">', $paged_page_nav );
//Add "current" class
$paged_page_nav = str_replace( '<span>', '<li class="'. $current_class .'">', $paged_page_nav );
$paged_page_nav = str_replace( '</span>', '</li>', $paged_page_nav );
echo  $paged_page_nav ;
}

Then call it in your single.php like so:

<?php my_link_pages(); ?>

Make sure that you add <!--nexpage--> on your Post Edit screen (Select Text NOT Visual)

Dejo Dekic
  • 909
  • 1
  • 11
  • 28