[wp-trac] [WordPress Trac] #35082: get_adjacent_post() when using in term doesn't account for child terms

WordPress Trac noreply at wordpress.org
Mon Dec 14 21:05:30 UTC 2015


#35082: get_adjacent_post() when using in term doesn't account for child terms
-------------------------------+-----------------------------
 Reporter:  WazzaJB            |      Owner:
     Type:  defect (bug)       |     Status:  new
 Priority:  normal             |  Milestone:  Awaiting Review
Component:  Posts, Post Types  |    Version:  trunk
 Severity:  normal             |   Keywords:
  Focuses:  template           |
-------------------------------+-----------------------------
 When using any of the next or previous post functions with $in_term set to
 true only top level terms are accounted for. This means if two posts are
 in the same child term, and a third is not but is between the posts date
 range then the third will take precedence.

 Although I am sure it will be up for discussion, I believe child terms
 should take priority.

 Take the following posts for example:

 '''Post 1'''
 Date: 01/01/2015
 Categories: Parent -> Child

 '''Post 2'''
 Date: 02/01/2015
 Categories: Parent

 '''Post 3'''
 Date: 01/01/2015
 Categories: Parent -> Child


 '''Expected Functionality (In my opinion):'''
 Post 1 get_adjacent_post(true) should return Post 3

 '''Actual Functionality:'''
 Post 1 get_adjacent_post(true) returns Post 2, which does not match the
 child term.

 My attached patch simply removes parent terms from the query, where a
 child of it is set. This means that only the deepest selected terms will
 be used, where children and parent terms are set.

 I have also attached an export of my posts to highlight the issue more
 clearly, along with a patch to Twenty Fifteen purely to help represent the
 issue.

 This really is just an initial draft suggestion for the code, backwards
 compatibility is obviously extremely important however more discussion
 about this is needed. There is another issue related to this function
 involving dates .

 Sorry if this should be tagged as an enhancement rather than a bug.

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


More information about the wp-trac mailing list