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

    Dear Kriesis,
    I’m creating a website with lots of posts and different categories. I set up pages and use the Avia Blog Post element to display posts filtered by categories in different ways. This works fine and provides an indivual layout for these pages and individual sidebars.

    The Problem is the breadcrumb navigation. As long as I navigate the page links in the main menu everything works fine. But as soon as I visit a single post the breadcrumb navigation switches to categories what is confusing.

    Styling the category archives is very limited and showing the archives is not wanted.

    Is it possible to hide the breadcrumb category navigation and display the page navigation on single posts with post name at the end of trail, as e.g.:
    Home / Auktionen(=page) / Premium Aktionen(=page) / Postname
    instead of:
    Home / Auktionen cat (=category) / Premiumauktionen cat(=category) / Postname
    ?
    I found some php-snippets in former support topics:

    add_filter( ‘avia_breadcrumbs_trail’, ‘remove_category_from_breadcrumb’, 50, 2, );
    function remove_category_from_breadcrumb( $trail, $args ) {
    if ( is_single() ) {
    unset ($trail[1]);
    unset ($trail[2]);
    }
    return $trail;
    }

    add_filter( ‘avia_breadcrumbs_args’, ‘avia_breadcrumbs_args_mod’, 10, 2 );
    function avia_breadcrumbs_args_mod( $args ) {
    // print_r($_SERVER);
    // [REQUEST_URI] => /category/auktionen-cat/e-auktionen/
    // print_r($args);
    $urlsWithoutCatShow = array(‘/auktionen-cat/’);
    foreach ($urlsWithoutCatShow as $url) {
    if (strpos($_SERVER[‘REQUEST_URI’], $url) !== false) {
    $args[‘show_categories’] = false;
    }
    }

    $args[‘show_categories’] = false;

    return $args;
    }

    At the moment these sripts are disabled in the functions.php in my Enfold childtheme. By enabling the categories are hide but the breadcrumb trail is too short and useless: Home / Postname

    I’m looking forward to any idea.
    Best regards
    Anne

    #1394681

    Hey annevoelkel,
    To remove that category from the breadcrumbs please use code to the end of your child theme functions.php file in Appearance ▸ Editor:

    add_filter( 'avia_breadcrumbs_trail', 'remove_category_from_breadcrumb', 50, 2, );
    function remove_category_from_breadcrumb( $trail, $args ) {
    if ( is_single() ) {
    unset ($trail[2]);
    }
    return $trail;
    }

    Without this function the breadcrumbs will show the category:
    Enfold_Support_146.jpeg
    With the function the category is removed:
    Enfold_Support_148.jpeg

    Best regards,
    Mike

    #1394755

    Hello Mike,
    thanks for the code. This works quite well. But it seems to be impossible to mix pages and blog posts in the breadcrumb trail like this:
    Home / Auktionen(=page) / Premium Aktionen(=page) / Postname

    Best regards
    Anne

    #1394766

    Hi,
    Glad this helps, the breadcrumbs for posts are for their relationship to the blog.
    Pages are shown the breadcrumbs in their relationship to their parent page.
    I don’t see where you could have a mix of pages and posts.

    Best regards,
    Mike

    #1394767

    Hello Mike,
    I understand and it is also logical.
    Best regards
    Anne

    #1394772

    Hi,
    Glad we were able to help, if you have any further questions please create a new thread and we will gladly try to help you. Thank you for using Enfold.

    Best regards,
    Mike

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘disable categories in breadcrumb navigation’ is closed to new replies.