Return false instead of WP_Error from get_term_by() if the term does not exist. Makes fetching a term by id consistent with slug and name. Props hakre. fixes #16464 #16717 for trunk

git-svn-id: https://develop.svn.wordpress.org/trunk@17526 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren
2011-03-22 20:06:38 +00:00
parent 1359ecd06b
commit 52cbde8270
2 changed files with 6 additions and 3 deletions

View File

@@ -2190,7 +2190,7 @@ class WP_Query {
if ( !empty( $cat_query ) ) {
$cat_query = reset( $cat_query );
$the_cat = get_term_by( $cat_query['field'], $cat_query['terms'][0], 'category' );
if ( $the_cat && ! is_wp_error( $the_cat ) ) {
if ( $the_cat ) {
$this->set( 'cat', $the_cat->term_id );
$this->set( 'category_name', $the_cat->slug );
}
@@ -2202,7 +2202,7 @@ class WP_Query {
if ( !empty( $tag_query ) ) {
$tag_query = reset( $tag_query );
$the_tag = get_term_by( $tag_query['field'], $tag_query['terms'][0], 'post_tag' );
if ( $the_tag && ! is_wp_error( $the_tag ) ) {
if ( $the_tag ) {
$this->set( 'tag_id', $the_tag->term_id );
}
unset( $the_tag );