[wp-trac] [WordPress Trac] #20243: New variable in WP_query class to state URLs for archive pages have multiple terms

WordPress Trac wp-trac at lists.automattic.com
Thu Mar 15 14:04:58 UTC 2012


#20243: New variable in WP_query class to state URLs for archive pages have
multiple terms
-------------------------+-----------------------------
 Reporter:  egorpromo    |      Owner:
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:  Awaiting Review
Component:  Taxonomy     |    Version:
 Severity:  normal       |   Keywords:
-------------------------+-----------------------------
 Sometimes site architecture demand is not to showing pages with multiple
 terms of taxonomy (not to showing two or more categories for posts, or not
 to showing two or more post tags, for example) in one archive pages. It is
 because this is bad for SEO (Search Engine Optimization) in some cases,
 and it is bad if archive pages with multiple terms of taxonomy be found in
 search engine result page. In some cases these pages can be indexed by
 google and sometimes (but not always) it is bad for site architecture.
 So, “wrong” pages may be something like:

 http://example.com/?cat=1,2 [[BR]]
 http://example.com/?cat=2,-5 [[BR]]
 http://example.com/category/cat1+cat2/ [[BR]]
 http://example.com/{custom-taxonomy}/{term1}+{term2}/ [[BR]]
 ...and so on.

 But needed only: [[BR]]
 http://example.com/?cat=1 [[BR]]
 http://example.com/?cat=2 [[BR]]
 http://example.com/?cat=5 [[BR]]
 http://example.com/category/cat1/ [[BR]]
 http://example.com/category/cat2/ [[BR]]
 http://example.com/{custom-taxonomy}/{term1} [[BR]]
 http://example.com/{custom-taxonomy}/{term2} [[BR]]
 …and so on. In examples I want to get all children terms also.

 I propose to use new variable (named WP_Query::single_term or similar ) in
 WP_Query class to state whether multiple terms of taxonomy in URL or not.
 So I can use code like this:

 {{{
 global $wp_query;
 if ($wp_query->single_term == TRUE )
 { //Fine. All is correct for my site. Go on.

 }
 elseif ($wp_query->single_term == FALSE  )
 {
 //May be not fine. It is page with multiple terms or similar. I have no
 template for this case and my site architecture don’t allow pages with
 multiple terms in URL. I must return page 404 or redirect to another page.

 }
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/20243>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list