[Plugin: Yoast Breadcrumbs] Obscure Bug in Post Preview
-
Hi,
A StudioPress user found a bug in the breadcrumbs.php file that comes with our themes. It’s very obscure.
When a post is previewed and has no categories selected it will not return a category and get_the_category() will return an empty array instead of an array of objects.
In your files, yoast-breadcrumbs.php needs to be changed:
if (is_single() && $opt['singlecatprefix']) { $cats = get_the_category(); $cat = $cats[0]; if ($cat->parent != 0) { $output .= get_category_parents($cat->term_id, true, " ".$opt['sep']." "); } else { $output .= '<a href="'.get_category_link($cat->term_id).'">'.$cat->name.'</a> '.$opt['sep'].' '; } }
Can be re-written as:
if (is_single() && $opt['singlecatprefix']) { $cats = get_the_category(); $cat = $cats[0]; if ( is_object($cat) ) { if ($cat->parent != 0) { $output .= get_category_parents($cat->term_id, true, " ".$opt['sep']." "); } else { $output .= '<a href="'.get_category_link($cat->term_id).'">'.$cat->name.'</a> '.$opt['sep'].' '; } } }
HTH,
–Charles
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘[Plugin: Yoast Breadcrumbs] Obscure Bug in Post Preview’ is closed to new replies.