Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #701614

    I have noticed that the breadcrumbs on my new site which I have uploaded to the hosting account do not seem to show the correct paths when viewed via the hamburger menu (i.e shrink the browser window and use hamburger for navigation). The same behaviour happens on the development version on my local machine.

    When I click on Portfolio->Cufflinks – the breadcrumb shows Home/Cufflinks/Cufflinks instead of Home/Portfolio/Cufflinks. Depending on which pages you have visited, the breadcrumb sometimes shows Home/Pendants/Cufflinks which is also wrong. Returning the browser to full-size does not correct the breadcrumb. The same is happening for other menu items.

    I have seen other questions relating to similar issues. Can you please advise.

    #702245

    Hey AlanGRutter,

    I have added this code in functions.php of your Child Theme:

    add_filter('avia_breadcrumbs_trail', 'avia_change_breadcrumb', 20, 1);
    function avia_change_breadcrumb($trail) {
    
      if(is_single() && get_post_type() == "portfolio")
      {
        $newtrail     = array();
        $portfolio_id = 77; //change portfolio id here
        $frontpage    = avia_get_option('frontpage'); 
    
        $newtrail[0] = '<a href="' . get_permalink( $frontpage ) . '" title="Home" rel="nofollow">Home</a>'; 
        $newtrail[1] = '<a href="' . get_permalink( $portfolio_id ) . '" title="' . esc_attr( get_the_title( $portfolio_id ) ) . '" rel="nofollow">' . get_the_title( $portfolio_id ) . '</a>'; 
        $newtrail['trail_end'] = $trail['trail_end'];
    
        $trail = $newtrail;
      }
      return $trail;
    }

    This should fix the issue. Please let us know if you experience any issues on the breadcrumb after this code has been added :)

    Best regards,
    Nikko

    • This reply was modified 8 years ago by Nikko.
    #702711

    Better but now the Pendant links are incorrect. I have two pages Portfolio which shows Cufflinks, Bracelets and Earrings and a separate page Pendants which shows the different types of pendants. The first show as

    Home -> Portfolio -> Cufflinks
    Home -> Portfolio -> Bracelets
    Home -> Portfolio -> Earrings

    and the Pendants show as Home -> Pendants with sub-categories like Home -> Pendants -> Layered.

    I ideally wanted Pendants under Portfolio, so that it would show Home -> Portfolio -> Pendants -> Layered, but I didn’t want the main Portfolio page showing all the subcategories of Pendants, just Pendants.

    Why is this happening in the first place – it only seems to be an issue from the hamburger menu not the normal menu. Is this a bug in the Enfold theme code??

    #703594

    Hi,

    Why did you create “Pendants” as a page and others as portfolio items? The filter above will only work for the single post page or items with portfolio as post type.

    Best regards,
    Ismael

    #704145

    Pendants is a parent category for other portfolio items. My portfolio items such as Layered belongs to both the Pendant and Layered (a sub-category of Pendants) categories. In the Masonry Gallery, even though I only selected Pendants, it showed both Pendants and Layered. My client did not want this, so I created a separate page for Pendants with a second Masonry Gallery to show the different sub-categories of Pendants.

    The breadcrumbs worked fine on a full-screen display without any additional code. They only seem to be messed up when you have a smaller screen and use the hamburger menu to navigate. It is the hamburger menu that screws it up.

    Regards
    Alan

    #705484

    Hi,

    Before giving the code I have checked the breadcrumbs, I tested it several times and noticed that when I clicked Braces the breadcrumbs is Home / Portfolio / Braces but when I clicked on Pendant then open Braces, the breadcrumb becomes Home / Pendants / Braces this is on desktop, tablet or mobile.

    I have tried to change the code I gave unfortunately I accidentally forgot to add ) which causes error. Can you replace the code in functions.php (you can change this via ftp or cpanel) to:

    add_filter('avia_breadcrumbs_trail', 'avia_change_breadcrumb', 20, 1);
    function avia_change_breadcrumb($trail) {
    
      if(is_single() && get_post_type() == "portfolio")
      {
        $newtrail     = array();
        $portfolio_id = 77; //change portfolio id here
        $pendant_id   = 253; //change pendant id here
        $frontpage    = avia_get_option('frontpage'); 
    
        $newtrail[0] = '<a href="' . get_permalink( $frontpage ) . '" title="Home">Home</a>'; 
        if( is_tax( 'portfolio_entries', 'pendants') ) {
            $newtrail[1] = '<a href="' . get_permalink( $pendant_id ) . '" title="' . esc_attr( get_the_title( $pendant_id ) ) . '">' . get_the_title( $pendant_id ) . '</a>'; 
        } else {
            $newtrail[1] = '<a href="' . get_permalink( $portfolio_id ) . '" title="' . esc_attr( get_the_title( $portfolio_id ) ) . '">' . get_the_title( $portfolio_id ) . '</a>'; 
        }
        $newtrail['trail_end'] = $trail['trail_end'];
    
        $trail = $newtrail;
      }
      return $trail;
    }

    I apologize for the mistake, let us know if it works.

    Best regards,
    Nikko

    • This reply was modified 8 years ago by Nikko.
    #705683

    Hi Nikko,

    I did have a mild heart attack when I saw the site since unfortunately your change coincided with my hosting company moving me to a different server as the one I was on seemed slow. I managed to get into the cPanel and fix the missing ‘)’ when I worked out where it was missing – I am a .NET programmer by trade so not an issue.

    It seems to work. Ismael was asking about the structure of me using a page for pendants instead of portfolio item. If there is a better way of doing it then I am open to suggestions as I am quite new to WordPress. I really wanted Home/Portfolio/Bracelets, Home/Portfolio/Pendants with subcategories like Home/Portfolio/Pendants/Layered but I couldn’t get this to work with the way that the Masonry Gallery selects parent and sub-categories. I only want the Portfolio page to show the top level categories (Bracelets,Cufflinks,Earring,Pendants,Other).

    Still learning ..

    Regards
    Alan

    #706842

    Hi,

    Try to add this replace the breadcrumb code I have given to this one:

    add_filter('avia_breadcrumbs_trail', 'avia_change_breadcrumb', 20, 1);
    function avia_change_breadcrumb($trail) 
    {
      if(is_single() && get_post_type() == "portfolio")
      {
        $newtrail     = array();
        $portfolio_id = 77; //change portfolio id here
        $pendant_id   = 253; //change pendant id here
        $portfolio_categories = array('pendants','etched','layered','painted','textured','other');
        $frontpage    = avia_get_option('frontpage'); 
    
        $newtrail[0] = '<a href="' . get_permalink( $frontpage ) . '" title="Home">Home</a>'; 
        if( has_term( $portfolio_categories, 'portfolio_entries') ) {
            $newtrail[1] = '<a href="' . get_permalink( $pendant_id ) . '" title="' . esc_attr( get_the_title( $pendant_id ) ) . '">' . get_the_title( $pendant_id ) . '</a>'; 
        } else {
            $newtrail[1] = '<a href="' . get_permalink( $portfolio_id ) . '" title="' . esc_attr( get_the_title( $portfolio_id ) ) . '">' . get_the_title( $portfolio_id ) . '</a>'; 
        }
        $newtrail['trail_end'] = $trail['trail_end'];
        $trail = $newtrail;
      }
      return $trail;
    }

    Let us know if it works. If not I would like to ask for ftp access, since it’s a bit risky editing functions.php in Appearance > Editor.

    As for the structure, it is best if it’s all Portfolio Entry instead of having a Page mixed with it. The code above won’t be needed and breadcrumbs will be functioning properly as long as all in the dropdown menu is using a single type (Portfolio Entry). Hope this helps :)

    Best regards,
    Nikko

    • This reply was modified 8 years ago by Nikko.
    #706927

    Hi Nikko,

    Your code is all good but it uses lots of magic numbers and is not very portable. As I have said before, the breadcrumbs work perfectly EXCEPT when using the hamburger menu, Nobody has yet explained why they should break when using the hamburger menu – what different code does it run.

    I will try to see if I can get a similar result using a Portfolio Entry – maybe I just won’t assign it a category.

    Regards
    Alan

    #706986

    Hey!

    Yes, it’s not a code that automatically solves the problem because you need to set 2 different parent pages. As for breadcrumbs not working properly on hamburger menu, the breadcrumb used in desktop is the same as the one used in mobile, I actually tested it on desktop and mobile and have the same issue as mentioned in my 2nd reply.

    Best regards,
    Nikko

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