Fix: Post without category breadcrumbs error

HomeForumsTechozoicFix: Post without category breadcrumbs error

This topic has 2 voices, contains 1 reply, and was last updated by  Jeremy Clark 162 days ago.

Viewing 2 posts - 1 through 2 (of 2 total)
Author Posts
Author Posts
November 12, 2011 at 10:38 am #1763

asmaloney

If you are using a plugin that includes custom post types you may run into the following PHP error:

[12-Nov-2011 19:27:32] PHP Catchable fatal error: Object of class WP_Error could not be converted to string in …/wp-content/themes/techozoic-fluid/functions.php on line 669

The problem is that the function tech_breadcrumbs() assumes that categories always exist for a post, so you end up with an error. To fix this, change this:

} elseif ( is_single() && !is_attachment() ) {
$cat = get_the_category();
$cat = $cat[0];
echo get_category_parents($cat, TRUE, ‘ ‘ . $delimiter . ‘ ‘);
echo $currentBefore;

to this:

} elseif ( is_single() && !is_attachment() ) {
$cat = get_the_category();
if ( $cat )
{
$cat = $cat[0];
echo get_category_parents($cat, TRUE, ‘ ‘ . $delimiter . ‘ ‘);
}
echo $currentBefore;

There are other problems with custom post type – the text “Filed in” still shows up for example, but this fix will at least let the page load…

December 7, 2011 at 4:23 am #1764

Jeremy Clark

Thanks I’ve incorporated this fix in the upcoming version.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.