0

I've added pagination to single.php, functionality is working as expected except for on the first page. wp is not recognizing when the current page is page 1, and is wrapping the first page span tag "1" with an active link.

When current page is Page 2

enter image description here

When current page is Page 1

enter image description here

<?php wp_link_pages( array(
        'before'      => '<div class="pagination">'  . __( 'Pages:' ),
        'after'       => '</div>',
        'link_before' => '<span>',
        'link_after'  => '</span>',
        ) );
?>

I'm wondering if it has to do with the body class, since page 2 has classes paged-2 and single-paged-2, and the first page doesnt not have any 'paged-' classes

1 Answer 1

0

I seem to have found the solution. In my theme I had previously set wordpress global variable $more to 0

<?php global $more; $more = 0; ?>

$more is a global boolean variable used to indicated whether or not wordpress should enforce the use of in a post to display a 'read more' link. wordpress does not enforce this is $more = true. This conflicts with page 1 when using the tag to paginate posts. Setting $more = 1 fixes this.

<?php global $more; $more = 1; ?>

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.