[wp-trac] [WordPress Trac] #16264: Add function get_pages_by_template()

WordPress Trac noreply at wordpress.org
Fri Feb 13 23:25:16 UTC 2015

#16264: Add function get_pages_by_template()
 Reporter:  mikeschinkel       |       Owner:
     Type:  feature request    |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Posts, Post Types  |     Version:  3.1
 Severity:  normal             |  Resolution:
 Keywords:  needs-refresh      |     Focuses:

Comment (by MikeSchinkel):

 Replying to [comment:9 helen]:
 > I don't see that this is a difficult helper function to implement when
 you need it (I mean, you've already written it here in the patch),

 Well, the biggest reason for the request was the 4 years ago I was trying
 to avoid the need for hardcoded SQL. IOW I was hoping to see the hardcoded
 SQL be baked into WordPress core where it can be become part of the
 documented API.  For example, for a project I am working on I was just
 reviewing [http://standards.10up.com/code/code-audits/ 10up's code audit
 standards] where it says ''"Overview of the Top 10 things we look for/ 2)
 Direct database queries / querying the database directly."'' So I wanted
 to be able to performantly query the database without using custom SQL.

 That said, the 2nd patch avoided custom SQL but is heavy compared with an
 optimized version of the patch which I could now write if there is any
 reason for me to make the effort ''(I've gotten much better with the
 WordPress API in the past 4 years and could improve this patch quite a

 > I'm not sure how many others are really looking for such a thing. I'm
 sure you personally use it frequently enough, but would like to gauge
 other developer interest as well.

 I have no idea how many others use it either, and maybe they don't.

 But if not I would wonder if they in fact should learn to do so?
 Effectively a page template implicitly defines a ''"Page Type"'' and we
 are constantly running into the need to create different page types. On
 every full site project we've ever worked on, actually.

 It would seem that our use-cases can't be that unique but maybe the reason
 others don't do this is because they only see a nail ''(i.e. taxonomies)''
 when core only provides them a hammer ''(i.e. no page types.)''


Ticket URL: <https://core.trac.wordpress.org/ticket/16264#comment:10>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list