[wp-trac] [WordPress Trac] #21620: Add conditional tag to check if current page is any of the blog-related pages

WordPress Trac wp-trac at lists.automattic.com
Sun Aug 19 04:49:21 UTC 2012


#21620: Add conditional tag to check if current page is any of the blog-related
pages
------------------------------------+------------------------------
 Reporter:  grantnorwood            |       Owner:
     Type:  enhancement             |      Status:  new
 Priority:  normal                  |   Milestone:  Awaiting Review
Component:  General                 |     Version:
 Severity:  normal                  |  Resolution:
 Keywords:  dev-feedback has-patch  |
------------------------------------+------------------------------
Changes (by greenshady):

 * cc: justin@… (added)


Comment:

 Neither `is_single()` nor `is_archive()` will work here.  Those check for
 any type of single view or archive for any post type.  Your checks would
 need to be:

 {{{
 is_home()
 is_singular( 'post' )

 is_author()
 is_date()
 is_time()
 }}}

 Only the first two are pretty sure bets though.  The others are all used
 in a myriad of ways with various post types.

 Your use of `get_post_type()` won't work as needed in the function.  It
 should only be used within The Loop in the manner that you're using it.
 Of course, you could pass the queried object on single views, but that's
 not the problem area.  So, the check's not really needed.

 Archives are where you run into trouble and anything goes.

 Honestly, I don't think we need a function for this because it can
 actually be pretty custom from site to site.  But, for your basic user,
 just tell them to use:

 {{{
 if ( is_home() || is_singular( 'post' ) )
 }}}

 That should cover most of their needs.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/21620#comment:3>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list