<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[13787] trunk/wp-includes/query.php:
  When viewing a Parent term in a hierarchical taxonomy,
  display objects contained within children too.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/13787">13787</a></dd>
<dt>Author</dt> <dd>dd32</dd>
<dt>Date</dt> <dd>2010-03-21 02:52:00 +0000 (Sun, 21 Mar 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>When viewing a Parent term in a hierarchical taxonomy, display objects contained within children too. Props scribu. Fixes <a href="http://trac.wordpress.org/ticket/12533">#12533</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludesqueryphp">trunk/wp-includes/query.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludesqueryphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/query.php (13786 => 13787)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/query.php        2010-03-21 02:29:11 UTC (rev 13786)
+++ trunk/wp-includes/query.php        2010-03-21 02:52:00 UTC (rev 13787)
</span><span class="lines">@@ -94,7 +94,7 @@
</span><span class="cx">  *
</span><span class="cx">  * @return bool True if page is archive.
</span><span class="cx">  */
</span><del>-function is_archive () {
</del><ins>+function is_archive() {
</ins><span class="cx">         global $wp_query;
</span><span class="cx"> 
</span><span class="cx">         return $wp_query-&gt;is_archive;
</span><span class="lines">@@ -108,7 +108,7 @@
</span><span class="cx">  *
</span><span class="cx">  * @return bool True if page is attachment.
</span><span class="cx">  */
</span><del>-function is_attachment () {
</del><ins>+function is_attachment() {
</ins><span class="cx">         global $wp_query;
</span><span class="cx"> 
</span><span class="cx">         return $wp_query-&gt;is_attachment;
</span><span class="lines">@@ -268,7 +268,7 @@
</span><span class="cx">  *
</span><span class="cx">  * @return bool
</span><span class="cx">  */
</span><del>-function is_comments_popup () {
</del><ins>+function is_comments_popup() {
</ins><span class="cx">         global $wp_query;
</span><span class="cx"> 
</span><span class="cx">         return $wp_query-&gt;is_comments_popup;
</span><span class="lines">@@ -282,7 +282,7 @@
</span><span class="cx">  *
</span><span class="cx">  * @return bool
</span><span class="cx">  */
</span><del>-function is_date () {
</del><ins>+function is_date() {
</ins><span class="cx">         global $wp_query;
</span><span class="cx"> 
</span><span class="cx">         return $wp_query-&gt;is_date;
</span><span class="lines">@@ -296,7 +296,7 @@
</span><span class="cx">  *
</span><span class="cx">  * @return bool
</span><span class="cx">  */
</span><del>-function is_day () {
</del><ins>+function is_day() {
</ins><span class="cx">         global $wp_query;
</span><span class="cx"> 
</span><span class="cx">         return $wp_query-&gt;is_day;
</span><span class="lines">@@ -310,7 +310,7 @@
</span><span class="cx">  *
</span><span class="cx">  * @return bool
</span><span class="cx">  */
</span><del>-function is_feed () {
</del><ins>+function is_feed() {
</ins><span class="cx">         global $wp_query;
</span><span class="cx"> 
</span><span class="cx">         return $wp_query-&gt;is_feed;
</span><span class="lines">@@ -324,7 +324,7 @@
</span><span class="cx">  *
</span><span class="cx">  * @return bool
</span><span class="cx">  */
</span><del>-function is_comment_feed () {
</del><ins>+function is_comment_feed() {
</ins><span class="cx">         global $wp_query;
</span><span class="cx"> 
</span><span class="cx">         return $wp_query-&gt;is_comment_feed;
</span><span class="lines">@@ -339,7 +339,7 @@
</span><span class="cx">  *
</span><span class="cx">  * @return bool True, if front of site.
</span><span class="cx">  */
</span><del>-function is_front_page () {
</del><ins>+function is_front_page() {
</ins><span class="cx">         // most likely case
</span><span class="cx">         if ( 'posts' == get_option('show_on_front') &amp;&amp; is_home() )
</span><span class="cx">                 return true;
</span><span class="lines">@@ -361,7 +361,7 @@
</span><span class="cx">  *
</span><span class="cx">  * @return bool True if blog view homepage.
</span><span class="cx">  */
</span><del>-function is_home () {
</del><ins>+function is_home() {
</ins><span class="cx">         global $wp_query;
</span><span class="cx"> 
</span><span class="cx">         return $wp_query-&gt;is_home;
</span><span class="lines">@@ -375,7 +375,7 @@
</span><span class="cx">  *
</span><span class="cx">  * @return bool
</span><span class="cx">  */
</span><del>-function is_month () {
</del><ins>+function is_month() {
</ins><span class="cx">         global $wp_query;
</span><span class="cx"> 
</span><span class="cx">         return $wp_query-&gt;is_month;
</span><span class="lines">@@ -429,7 +429,7 @@
</span><span class="cx">  *
</span><span class="cx">  * @return bool
</span><span class="cx">  */
</span><del>-function is_paged () {
</del><ins>+function is_paged() {
</ins><span class="cx">         global $wp_query;
</span><span class="cx"> 
</span><span class="cx">         return $wp_query-&gt;is_paged;
</span><span class="lines">@@ -491,7 +491,7 @@
</span><span class="cx">  *
</span><span class="cx">  * @return bool
</span><span class="cx">  */
</span><del>-function is_search () {
</del><ins>+function is_search() {
</ins><span class="cx">         global $wp_query;
</span><span class="cx"> 
</span><span class="cx">         return $wp_query-&gt;is_search;
</span><span class="lines">@@ -512,7 +512,7 @@
</span><span class="cx">  * @param mixed $post Either post or list of posts to test against.
</span><span class="cx">  * @return bool
</span><span class="cx">  */
</span><del>-function is_single ($post = '') {
</del><ins>+function is_single($post = '') {
</ins><span class="cx">         global $wp_query;
</span><span class="cx"> 
</span><span class="cx">         if ( !$wp_query-&gt;is_single )
</span><span class="lines">@@ -557,7 +557,7 @@
</span><span class="cx">  *
</span><span class="cx">  * @return bool
</span><span class="cx">  */
</span><del>-function is_time () {
</del><ins>+function is_time() {
</ins><span class="cx">         global $wp_query;
</span><span class="cx"> 
</span><span class="cx">         return $wp_query-&gt;is_time;
</span><span class="lines">@@ -571,7 +571,7 @@
</span><span class="cx">  *
</span><span class="cx">  * @return bool
</span><span class="cx">  */
</span><del>-function is_trackback () {
</del><ins>+function is_trackback() {
</ins><span class="cx">         global $wp_query;
</span><span class="cx"> 
</span><span class="cx">         return $wp_query-&gt;is_trackback;
</span><span class="lines">@@ -585,7 +585,7 @@
</span><span class="cx">  *
</span><span class="cx">  * @return bool
</span><span class="cx">  */
</span><del>-function is_year () {
</del><ins>+function is_year() {
</ins><span class="cx">         global $wp_query;
</span><span class="cx"> 
</span><span class="cx">         return $wp_query-&gt;is_year;
</span><span class="lines">@@ -599,7 +599,7 @@
</span><span class="cx">  *
</span><span class="cx">  * @return bool True, if nothing is found matching WordPress Query.
</span><span class="cx">  */
</span><del>-function is_404 () {
</del><ins>+function is_404() {
</ins><span class="cx">         global $wp_query;
</span><span class="cx"> 
</span><span class="cx">         return $wp_query-&gt;is_404;
</span><span class="lines">@@ -1134,7 +1134,7 @@
</span><span class="cx">          * @since 1.5.0
</span><span class="cx">          * @access public
</span><span class="cx">          */
</span><del>-        function init () {
</del><ins>+        function init() {
</ins><span class="cx">                 unset($this-&gt;posts);
</span><span class="cx">                 unset($this-&gt;query);
</span><span class="cx">                 $this-&gt;query_vars = array();
</span><span class="lines">@@ -1227,7 +1227,7 @@
</span><span class="cx">          *
</span><span class="cx">          * @param string|array $query
</span><span class="cx">          */
</span><del>-        function parse_query ($query) {
</del><ins>+        function parse_query($query) {
</ins><span class="cx">                 if ( !empty($query) || !isset($this-&gt;query) ) {
</span><span class="cx">                         $this-&gt;init();
</span><span class="cx">                         if ( is_array($query) )
</span><span class="lines">@@ -1996,23 +1996,29 @@
</span><span class="cx">                         if ( '' != $q['taxonomy'] ) {
</span><span class="cx">                                 $taxonomy = $q['taxonomy'];
</span><span class="cx">                                 $tt[$taxonomy] = $q['term'];
</span><del>-                                $terms = get_terms($q['taxonomy'], array('slug'=&gt;$q['term']));
</del><span class="cx">                         } else {
</span><span class="cx">                                 foreach ( $GLOBALS['wp_taxonomies'] as $taxonomy =&gt; $t ) {
</span><span class="cx">                                         if ( $t-&gt;query_var &amp;&amp; '' != $q[$t-&gt;query_var] ) {
</span><del>-                                                $terms = get_terms($taxonomy, array('slug'=&gt;$q[$t-&gt;query_var]));
-                                                if ( !is_wp_error($terms) )
-                                                        break;
</del><ins>+                                                $tt[$taxonomy] = $q[$t-&gt;query_var];
+                                                break;
</ins><span class="cx">                                         }
</span><span class="cx">                                 }
</span><span class="cx">                         }
</span><ins>+
+                        $terms = get_terms($taxonomy, array('slug' =&gt; $tt[$taxonomy], 'hide_empty' =&gt; !is_taxonomy_hierarchical($taxonomy)));
+
</ins><span class="cx">                         if ( is_wp_error($terms) || empty($terms) ) {
</span><span class="cx">                                 $whichcat = &quot; AND 0 &quot;;
</span><span class="cx">                         } else {
</span><del>-                                foreach ( $terms as $term )
</del><ins>+                                foreach ( $terms as $term ) {
</ins><span class="cx">                                         $term_ids[] = $term-&gt;term_id;
</span><ins>+                                        if ( is_taxonomy_hierarchical($taxonomy) ) {
+                                                $children = get_term_children($term-&gt;term_id, $taxonomy);
+                                                $term_ids = array_merge($term_ids, $children);
+                                        }
+                                }
</ins><span class="cx">                                 $post_ids = get_objects_in_term($term_ids, $taxonomy);
</span><del>-                                if ( !is_wp_error($post_ids) &amp;&amp; count($post_ids) ) {
</del><ins>+                                if ( !is_wp_error($post_ids) &amp;&amp; !empty($post_ids) ) {
</ins><span class="cx">                                         $whichcat .= &quot; AND $wpdb-&gt;posts.ID IN (&quot; . implode(', ', $post_ids) . &quot;) &quot;;
</span><span class="cx">                                         $post_type = 'any';
</span><span class="cx">                                         $q['post_status'] = 'publish';
</span><span class="lines">@@ -2734,7 +2740,7 @@
</span><span class="cx">          * @param string $query URL query string.
</span><span class="cx">          * @return WP_Query
</span><span class="cx">          */
</span><del>-        function WP_Query ($query = '') {
</del><ins>+        function WP_Query($query = '') {
</ins><span class="cx">                 if (! empty($query)) {
</span><span class="cx">                         $this-&gt;query($query);
</span><span class="cx">                 }
</span><span class="lines">@@ -2752,7 +2758,7 @@
</span><span class="cx">  *
</span><span class="cx">  * @return null If no link is found, null is returned.
</span><span class="cx">  */
</span><del>-function wp_old_slug_redirect () {
</del><ins>+function wp_old_slug_redirect() {
</ins><span class="cx">         global $wp_query;
</span><span class="cx">         if ( is_404() &amp;&amp; '' != $wp_query-&gt;query_vars['name'] ) :
</span><span class="cx">                 global $wpdb;
</span><span class="lines">@@ -2826,5 +2832,4 @@
</span><span class="cx"> 
</span><span class="cx">         return true;
</span><span class="cx"> }
</span><del>-
-?&gt;
</del><span class="cx">\ No newline at end of file
</span><ins>+?&gt;
</ins></span></pre>
</div>
</div>

</body>
</html>