admin管理员组文章数量:1434889
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
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!
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
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!
Share Improve this question asked Apr 1, 2019 at 19:03 DiscoverDiscover 331 gold badge1 silver badge6 bronze badges1 Answer
Reset to default 0It 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?
本文标签: wp link pagesPost Pagination Customization (wplinkpages) Editing Navigation
版权声明:本文标题:wp link pages - Post Pagination Customization (wp_link_pages) Editing Navigation 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745638657a2667718.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论