Reputation: 722
I'm creating the pre/next posts navigator using the following code in wordpress 4.8 and php 7:
<span class="nav-previous"><?php previous_post_link('« %link', '%title', true); ?></span>
<span class="nav-next"><?php next_post_link('%link »', '%title', true); ?></span>
The previous link works well, but the next link never displayed.
Then I tried the following code:
<span class="nav-previous"><?php previous_post_link('« %link', '%title', true); ?></span>
<?php next_post_link('%link »', '%title', true); ?>
<span class="nav-next"><?php next_post_link('%link »', '%title', true); ?></span>
It calls next_post_link twice, and now it works as expected. However, this solution is simple and ugly. I beleive there is something wrong with my code or wordpress settings.
Here is the whole malfunction code snippet:
<?php if ( array_intersect($excluded_terms, $categories_id_list) ) { ?>
<span class="nav-previous"><?php previous_post_link('« %link', '%title', true); ?></span>
<span class="nav-next"><?php next_post_link('%link »', '%title', true); ?></span>
<?php } else { ?>
<span class="nav-previous"><?php previous_post_link('« %link', '%title', false, $excluded_terms); ?></span>
<span class="nav-next"><?php next_post_link('%link »', '%title', false, $excluded_terms); ?></span>
<?php } ?>
Only previous_post_link shows correctly.
Here is a list of installed and enable plugins on my site:
Any suggestion would appreicate.
Upvotes: 1
Views: 71