1

I want to create a post pagination where there is only ONE 'nextpagelink' button per page.

However, I want the text inside the the first 'nextpagelink' to say "WELCOME".

And I want the text inside every 'nextpagelink' after that to say "NEXT PAGE".

Quick Schematic

enter image description here

I figured out the "NEXT PAGE" part:

The following is inside single.php

wp_link_pages( array(
'before' => '<div id="slideshow">',
'after' => '</div>',
'next_or_number' => 'next', 
'previouspagelink' => '<span id="previous" style="display:none;"> PREVIOUS SLIDE </span>',  
'nextpagelink' => '<span id="next"> NEXT PAGE </span>'
)); ?>

The problem is that it makes ALL 'nextpagelink' "NEXT PAGE"

I am trying the following but its not really working:

The following is inside post-template.php

            if ( $next = 1 ) {
            $link = _wp_link_page( $next ) . $r['link_before'] . $r['nextpagelink_first'] . $r['link_after'] . '</a>';

Where "nextpagelink_first" = 'WELCOME'

All that does is display 'WELCOME' next to 'NEXT PAGE', and 'WELCOME' always points to first slide, not good.

Please help!

1

It makes all pages show "NEXT PAGE", because you don't tell it that it should be any different.

What you need is to set that link conditionally based on which page is currently displayed:

wp_link_pages( array(
    'before' => '<div id="slideshow">',
    'after' => '</div>',
    'next_or_number' => 'next', 
    'previouspagelink' => '<span id="previous" style="display:none;"> PREVIOUS SLIDE </span>',  
    'nextpagelink' => ( get_query_var('page') < 2 ) ? '<span id="next"> WELCOME </span>' : '<span id="next"> NEXT PAGE </span>'
) );

This uses a conditional statement:

( get_query_var('page') < 2 ) ? '<span id="next"> WELCOME </span>' : '<span id="next"> NEXT PAGE </span>'

which checks the current page (you can get it by checking page query var) and returning one of the strings based on the condition (here we check if it's the first page or any other).

You can read more on page query var here: What is the difference between $paged and $page?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.