Make WordPress Core

Changeset 3385


Ignore:
Timestamp:
12/31/2005 09:53:13 PM (19 years ago)
Author:
ryan
Message:

Fallback to matching the leaf category if the full path doesn't match. Props David House. fixes #2161

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/classes.php

    r3373 r3385  
    486486
    487487            $all_cat_ids = get_all_category_ids();
    488             $q['cat'] = 0;         
     488            $q['cat'] = 0; $partial_match = 0;
    489489            foreach ( $all_cat_ids as $cat_id ) {
    490490                $cat = get_category($cat_id);
     
    492492                    $q['cat'] = $cat_id;
    493493                    break;
    494                 }
    495             }
     494                } elseif ( $cat->category_nicename == $q['category_name'] ) {
     495                    $partial_match = $cat_id;
     496                }
     497            }
     498           
     499            //if we don't match the entire hierarchy fallback on just matching the nicename
     500            if (!$q['cat'] && $partial_match) {
     501                $q['cat'] = $partial_match;
     502            }           
    496503
    497504            $tables = ", $wpdb->post2cat, $wpdb->categories";
Note: See TracChangeset for help on using the changeset viewer.