admin管理员组

文章数量:1425662

A quick question. So I have created a loop in a new file called sidebar-extra.php which I include via the header.php into my single.php file.

Problem: when I go to a post (single.php), I can't see this navigation, while I can see it on my homepage, where I also include sidebar-extra.php

<ul class="pagination">
        <li class="page-item"><?php previous_posts_link('&laquo; Previous posts') ?></li>
        <li class="page-item"><?php next_posts_link('Next posts &raquo;') ?></li>
    </ul>

Is there a way I can make sure that my sidebar-extra.php is showing the post navigation everywhere, including on single.php?

A quick question. So I have created a loop in a new file called sidebar-extra.php which I include via the header.php into my single.php file.

Problem: when I go to a post (single.php), I can't see this navigation, while I can see it on my homepage, where I also include sidebar-extra.php

<ul class="pagination">
        <li class="page-item"><?php previous_posts_link('&laquo; Previous posts') ?></li>
        <li class="page-item"><?php next_posts_link('Next posts &raquo;') ?></li>
    </ul>

Is there a way I can make sure that my sidebar-extra.php is showing the post navigation everywhere, including on single.php?

Share Improve this question asked May 27, 2019 at 16:51 SiyahSiyah 1932 silver badges12 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

You’re using previous_posts_link (and next_posts_link) function in your code.

This function prints a link to the previous set of posts within the current query. So they are meant for posts archives.

But if you’re on single page/post, so there is only one post in the query - the one that is shown. So these links won’t be available.

When seeing a single post, you should be using previous_post_link instead (singular post and not posts).

本文标签: navigationSidebar pagination posts not shown when sidebar is in singlephp