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('« Previous posts') ?></li>
<li class="page-item"><?php next_posts_link('Next posts »') ?></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('« Previous posts') ?></li>
<li class="page-item"><?php next_posts_link('Next posts »') ?></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
?
1 Answer
Reset to default 0You’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
版权声明:本文标题:navigation - Sidebar pagination posts not shown when sidebar is in single.php 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745458504a2659216.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论