[wp-trac] [WordPress Trac] #33860: Loop helpers function

WordPress Trac noreply at wordpress.org
Sat Oct 17 12:13:21 UTC 2015


#33860: Loop helpers function
-------------------------------------------------+-------------------------
 Reporter:  sebastian.pisula                     |       Owner:
     Type:  enhancement                          |      Status:  new
 Priority:  normal                               |   Milestone:  Awaiting
Component:  Query                                |  Review
 Severity:  normal                               |     Version:  4.3
 Keywords:  has-patch 2nd-opinion good-first-    |  Resolution:
  bug has-unit-tests                             |     Focuses:  template
-------------------------------------------------+-------------------------
Changes (by swissspidy):

 * keywords:  has-patch needs-unit-tests 2nd-opinion good-first-bug => has-
     patch 2nd-opinion good-first-bug has-unit-tests


Comment:

 [attachment:33860.diff] adds three helper functions: `query_post_index()`,
 `query_is_first_post()` and `query_is_last_post()`. Including tests.

 Getting the first and last post is usually needed more often, as odd/even
 queries are usually used for styling only (which you can target with CSS).
 If you want to detect the odd/even post, you can create your own helper
 function leveraging `query_post_index()`.

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


More information about the wp-trac mailing list