Tagged: 

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1461600

    Hi
    I have an issue with the breadcrumb in the header. In the news section of the site there is an extra step in the breadcrumb that should NOT be there.
    When you access the news section, the breadcrumb reads Home/News, but when you click on the article the breadcrumb reads Home/News/News/name of article. The second news should not be there.

    When you acces the archive on the right side and click on moth year you get Home/News/Automatic draft/Year/Month. If you click on automatc draft you got to a 404 page, and if you click on one of the articles for that month we are back to Home/News/News/Name of article.

    How do I get rid of the second step and how is it even there?

    Regards
    Nina

    #1461749

    Hey Advantage09,

    Thank you for the inquiry.

    Did you create a category named “News”? It’s possible that both the page “News” and the category “News” are being included in the breadcrumb. If that’s not the case, you can add this filter to your functions.php file to remove the duplicate entry.

    function avia_breadcrumbs_trail_mod($trail)
    {
        // remove news trail
        if ( is_singular( 'post' ) ) {
            unset($trail[1]);
        }
        return $trail;
    }
    add_filter('avia_breadcrumbs_trail', 'avia_breadcrumbs_trail_mod', 50, 1);
    

    Best regards,
    Ismael

    #1461830

    Hi

    Yes, there is a category named nyheter (news), but there is no category named Automatic draft so I am not sure thats it.

    Trying your script removes the extra news and/or Automatic draft in the breadcrumb trail. BUT, when accessing the archive section on the right side and click on any random month year link you see the home/news/year/month but when clicking on the article itself the year and month dissapears. So clicking backwards in the breadcrumb trail is not possible. You have to start over again in the archive menu.
    Is there a way to keep the entire breadcrumb?

    Regards
    Nina

    #1461898

    Hi,

    Thank you for the update.

    In the single post page, the default breadcrumb structure is: Home > Blog Page > First Category > Post, which is why you’re seeing the “News” category in the breadcrumb. If you want to remove the category and include the archive date instead, you can use the following code in place of the previous filter:

    function avia_breadcrumbs_trail_mod($trail) {
        global $post;
    
        if ( is_singular( 'post' ) ) {
            $end = $trail['trail_end'];
            unset($trail['trail_end']);
            unset($trail[2]);
    
            $post_month = get_the_date('F Y', $post); 
            $trail[] = '<a href="' . get_month_link(get_post_time('Y'), get_post_time('m')) . '" title="' . esc_attr($post_month) . '" rel="">' . $post_month . '</a>';
    
            $post_year = get_the_date('Y', $post);
            $trail[] = '<a href="' . get_year_link($post_year) . '" title="' . esc_attr($post_year) . '" rel="">' . $post_year . '</a>';
    
            $trail[] = $end;
        }
    
        return $trail;
    }
    add_filter('avia_breadcrumbs_trail', 'avia_breadcrumbs_trail_mod', 50, 1);

    Best regards,
    Ismael

    #1462074

    This is somewhat ok. Not perfect, but I can live with it for now.

    Thanks

    Regards
    Nina

    #1462088

    Hi,

    Alright! Please feel free to open another thread if you have more questions about the theme.

    Have a nice day.

    Best regards,
    Ismael

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Breadcrumbs’ is closed to new replies.