[wp-trac] [WordPress Trac] #8107: get_next_post, get_previous_post do not work for posts posted within same second

WordPress Trac noreply at wordpress.org
Mon Mar 10 18:36:56 UTC 2014


#8107: get_next_post, get_previous_post do not work for posts posted within same
second
----------------------------------------+-----------------------------
 Reporter:  whoismanu                   |       Owner:
     Type:  defect (bug)                |      Status:  new
 Priority:  low                         |   Milestone:  Future Release
Component:  Posts, Post Types           |     Version:  2.7
 Severity:  minor                       |  Resolution:
 Keywords:  needs-testing dev-feedback  |     Focuses:  template
----------------------------------------+-----------------------------

Comment (by billerickson):

 What would the array_reverse() be applied to? We're querying for a single
 post ( 'posts_per_page' => 1 ).

 If you have two posts with the same datetime, then the adjacent post will
 always be the other one. Key query_vars:


 {{{
 'posts_per_page' => 1,
 'post__not_in' => array( $this->current_post->ID ),
 'date_query' => array(
   array(
       $date_query_key => $this->current_post->post_date,
       'inclusive' => true,
   )
 ),

 }}}

 Whether you're looking for previous or next, both posts will be included
 due to the inclusive line. And since we're excluding the current post, the
 other post will always be returned.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/8107#comment:17>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list