Permalink
Browse files

Avoid error notices when the terms don't actually exist. They might n…

…ot exist if the user has just installed Co-Authors Plus
  • Loading branch information...
1 parent 2537a82 commit 70d7a306c76bbfa3b9d13a185b740a13e50a1950 @danielbachhuber danielbachhuber committed Aug 6, 2012
Showing with 4 additions and 3 deletions.
  1. +4 −3 co-authors-plus.php
View
@@ -563,11 +563,12 @@ function posts_where_filter( $where, $query ){
$author_name = get_userdata( $query->get( 'author' ) )->user_login;
$terms = array();
- $terms[] = get_term_by( 'slug', $author_name, $this->coauthor_taxonomy );
+ if ( $author_term = get_term_by( 'slug', $author_name, $this->coauthor_taxonomy ) )
+ $terms[] = $author_term;
$coauthor = $this->get_coauthor_by( 'login', $author_name );
// If this coauthor has a linked account, we also need to get posts with those terms
- if ( !empty( $coauthor->linked_account ) ) {
- $terms[] = get_term_by( 'slug', $coauthor->linked_account, $this->coauthor_taxonomy );
+ if ( !empty( $coauthor->linked_account ) && $guest_author_term = get_term_by( 'slug', $author_name, $this->coauthor_taxonomy ) ) {
+ $terms[] = $guest_author_term;
}
// Whether or not to include the original 'post_author' value in the query

0 comments on commit 70d7a30

Please sign in to comment.