Opened 6 years ago
Closed 5 months ago
#49773 closed enhancement (invalid)
Navigating through list of posts on single.php is not functioning
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | major | Version: | 5.5 |
| Component: | Posts, Post Types | Keywords: | needs-testing 2nd-opinion reporter-feedback |
| Focuses: | template | Cc: |
Description
Wordpress is fantastic, but there are some flaws (at least from my perspective). I don't know if this can be classified as a bug or an enhancement, but WordPress expects that (single) pages could contain archive listings and might require pagination, yet single posts do not expected to have archive listings which is causing this issue. Instead of taking the page-slug/page/#/, it should take the post-slug/#/ when using the pagination in single.php.
What's happening is that the page # request portion is ignored and $paged will always be 1, and the “wrong” URL is rewritten to the “correct” one. Taking the $paged value from the main query and use it in a custom query often is problematic.
So, it does not allow us to add navigate through a list of posts in single.php. When using e.g. this snippet:
<div class="test">...</div>
<ul class="pagination">
<li class="page-item"><?php previous_posts_link('« Previous') ?></li>
<li class="page-item"><?php next_posts_link('Next »') ?></li>
</ul>
It will only spit out the HTML elements, but not the buttons, as there is nothing to show.
Another example:
<?php <?php // wp query $wp_query = new WP_Query( array( 'posts_per_page' => 25, 'paged' => $paged, ) ); $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; if ( $wp_query->have_posts() ) : ?> <!-- pagination here --> <!-- the loop --> <?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?> <li id="test" data-href="<?php $blink = get_the_permalink(); ;?>"> <div> <a id="test" href="<?php the_permalink(); ?>"><?php the_title(); ?></a> </div> </li> <?php endwhile; ?>
Nothing works. Best case scenario is that it adds a page, but you then get the following: websiteURL/post-url/page/number
And of course, that also does not work and therefore you can't scroll through posts as you like.
Can we get this checked and hopefully fixed, please? I am desperately waiting for this, and many more are like me (Stackoverflow is filled with these questions).
Change History (3)
#1
in reply to:
↑ description
@
6 years ago
- Focuses ui accessibility removed
- Keywords reporter-feedback added; needs-patch needs-dev-note removed
This ticket was mentioned in Slack in #core by sirlouen. View the logs.
5 months ago
#3
@
5 months ago
- Milestone Awaiting Review deleted
- Resolution set to invalid
- Status changed from new to closed
Given that some reporter feedback was asked 6 years ago but there have been no answer since then, it's time to close this now.
@1BJK903 feel free to comment back if you are still finding this trouble now and I will be happy to look into it. Check Sergey's inquiries and answer them accordingly.
Hi there, welcome to WordPress Trac! Thanks for the report.
Just to clarify, these are not the same thing:
/page/#/corresponds to thepagedquery variable that is used for various archives./#/corresponds to thepagequery variable that is used for post content separated with <!--nextpage--> tag in combination with wp_link_pages() in single post template.I know this might be confusing.
You're using the
$pagedvariable before it's defined. You should define it before$wp_query, not after.So far, I'm having trouble reproducing the issues. Сould you provide the steps to reproduce the issue on a clean install?