How to Fix the Error 'Home Catchable fatal error: Object of class WP_Error could not be converted to string in /home/computerites.com/wp-content/themes/computerites/functions.php on line 144'

 

Recently i found there is a error in my WordPress server logs.The error is "Home Catchable fatal error: Object of class WP_Error could not be converted to string in /home/computerites.com/wp-content/themes/computerites/functions.php on line 144".

I think this is due to the bread navigation.Because the page was not classified cause an error when get the page 's classification.So we can modify the code to fix this problem .

The  code is like this:
elseif ( is_single() )
{
$category = get_the_category();
$category_id = get_cat_ID( $category[0]->cat_name );
echo '<li> &gt; '. get_category_parents( $category_id, TRUE, "<li> &gt;" );
echo the_title('','', FALSE);
}

 

";
}

We modify it like this:

elseif ( is_single() )
{
$category = get_the_category();
$category_id = get_cat_ID( $category[0]->cat_name );
echo is_wp_error( $cat_parents = get_category_parents($category_id, TRUE, '<li> &gt; ') ) ? '&gt; ' : '&gt; '.$cat_parents;
echo the_title('','', FALSE) ;
}

Then we can fix this error.



This address is http://www.computerites.com/web-design-skills/2014/12/how-to-fix-the-error-home-catchable-fatal-error-object-of-class-wp_error-could-not-be-converted-to-string-in-homecomputerites-comwp-contentthemescomputeritesfunctions-php-on-line-144-769.html