What does this mean: Object of class WP_Error could not be converted to string

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

Read More

The line 288 is as follows

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

Any ideas on this please?

Related posts

Leave a Reply

1 comment

  1. 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;