[wp-trac] [WordPress Trac] #49773: Navigating through list of posts on single.php is not functioning

WordPress Trac noreply at wordpress.org
Wed Apr 1 23:30:54 UTC 2020


#49773: Navigating through list of posts on single.php is not functioning
-------------------------------------+-------------------------------------
 Reporter:  1BJK903                  |      Owner:  (none)
     Type:  enhancement              |     Status:  new
 Priority:  normal                   |  Milestone:  Awaiting Review
Component:  Posts, Post Types        |    Version:  trunk
 Severity:  major                    |   Keywords:  needs-testing needs-
  Focuses:  ui, accessibility,       |  patch 2nd-opinion needs-dev-note
  template                           |
-------------------------------------+-------------------------------------
 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
                 <?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).

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/49773>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list