From b89beae1461458102f29a7c635a60048d50acc31 Mon Sep 17 00:00:00 2001 From: mateuswetah Date: Fri, 30 Jul 2021 09:45:56 -0300 Subject: [PATCH] Fixes breadcrum issue on attachment pages. --- src/functions/breadcrumb.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/functions/breadcrumb.php b/src/functions/breadcrumb.php index ac122ae..aba18d4 100644 --- a/src/functions/breadcrumb.php +++ b/src/functions/breadcrumb.php @@ -104,10 +104,15 @@ function tainacan_interface_the_breadcrumb() { } } elseif ( is_attachment() ) { $parent = get_post($post->post_parent); - $cat = get_the_category($parent->ID); $cat = $cat[0]; - echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' '); - echo '' . $parent->post_title . ''; - if ($showCurrent == 1) echo ' ' . $delimiter . ' ' . $before . get_the_title() . $after; + + $cat = get_the_category($parent->ID); + if ( !empty($cat) && is_array($cat) && count($cat) ) { + $cat = $cat[0]; + echo get_category_parents($cat, TRUE, ' ' . $delimiter . ' '); + echo '' . $parent->post_title . ' ' . $delimiter; + } + if ($showCurrent == 1) + echo ' ' . $before . get_the_title() . $after; } elseif ( is_page() && !$post->post_parent ) { if ($showCurrent == 1) echo $before . get_the_title() . $after;