Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #286718

    HI there,
    I was wondering how I can ensure the inclusion of page categories into the breadcrumbs?
    At present, it only shows:
    Home / My Page Title
    Instead of:
    Home / My Category / My Page Title

    It works fine for posts, and I can select it manually for portfolio pages, but no option exists for standard pages.
    Could you please advise me as to how I can sort this out.
    Thanks in advance for your help, and if you require any additional information, please let me know.
    Kind regards,
    Chris

    #287057

    Hi OpenEyeMedia!

    Thank you for using the theme.

    Did you use a plugin to add category on pages? Please add this on functions.php:

    add_filter('avia_breadcrumbs_trail', 'avia_change_breadcrumb', 5, 1);
    function avia_change_breadcrumb($trail) {
        if(is_page())
        {
            global $post;
    
            $front 			= avia_get_option('frontpage');
            $blog 			= avia_get_option('blogpage');
    
            if($post->ID == $blog || $post->ID == $front) return $trail;
    
            $category = get_the_category($post->ID);
            if(!empty($category))
            {
                $home = $trail[0];
                $last = array_pop($trail);
                $trail = array(0 => $home);
    
                foreach($category as $key => $data)
                {
                    $link = '<a href="'.get_category_link($data).'">'.$data->name.'</a>';
                    $link = preg_replace('!rel=".+?"|rel=\'.+?\'|!',"", $link);
                    $link = str_replace('<a ', '<a rel="v:url" property="v:title" ', $link);
                    $link = '<span typeof="v:Breadcrumb">'.$link.'</span>';
                    $trail[] = $link;
                }
    
                $trail[] = $last;
            }
        }
        return $trail;
    }

    Cheers!
    Ismael

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.