Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

When I click on preview a post, I get the following error:

Catchable fatal error: Object of class WP_Error could not be converted to string in functions.php on line 288

The line 288 is as follows

echo get_category_parents($cat, TRUE, '' . $delimiter . '');

Any ideas on this please?

share|improve this question

1 Answer 1

up vote 5 down vote accepted

The only way that function returns an instance of WP_Error is if $cat (in your example) has an empty value. You need to check the return before doing anything with it. Replacing that line with this should fix the problem:

echo is_wp_error( $cat_parents = get_category_parents($cat, TRUE, '' . $delimiter . '') ) ? '' : $cat_parents;
share|improve this answer

protected by Community Dec 7 '12 at 14:53

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.