Viewing 17 posts - 1 through 17 (of 17 total)
  • Author
    Posts
  • #413551

    Hi team,
    I am redesigning my web (now in Joomla) to WP with Enfold, using mainly Pages (not Posts Entries).

    In my current Joomla web, the sidebar menu and breadcrumbs show the Menu Item name of the Page, not the Title of the page.
    For instance:

    Title of the page : ¿What do participants say?
    menú item name of the page: Opinions (under menú item “Company”)

    Breadcrumbs shows Home/Company/Opinions
    Sidebar Navigation menú shows:
    Company
    Opinions

    But in WP/ENFOLD, Sidebar Menu and Breadcrumbs show Title of the page (which is usually longer than menu items), and I wouldn’t like to change the Title of my pages, since I have already a SEO position in Google, etc..

    Breadcrumbs shows Home/Company/¿What do participants say?
    Sidebar Navigation menú shows:
    Company
    ¿What do participants say?

    I would need that in WP/ENFOLD breadcrumbs and sidebar show menu item name instead of page title
    Is there any way to get it?
    Maybe a plugin? Or with some code?

    Thanks a lot for your help!

    #414668

    Hi blanchrosa!

    Can you please post the link to your Enfold website? :)

    Cheers!
    Yigit

    #414776
    This reply has been marked as private.
    #414786

    Hey!

    Yes, we are going to need a temporary admin login in order to see the content of your website. You can use (Email address hidden if logged out) email but please post login credentials here privately so any available moderator can look into it

    Regards,
    Yigit

    #414818
    This reply has been marked as private.
    #415644

    Hi!

    To change the breadcrumb to the page menu item instead of the title of the menu, you can add this to the functions.php:

    add_filter('avia_breadcrumbs_trail', 'avia_change_breadcrumb', 20, 1);
    function avia_change_breadcrumb($trail) {
    	$menu_name = 'avia';
    	$id = get_the_ID();
    	
        if ( ( $locations = get_nav_menu_locations() ) && isset( $locations[ $menu_name ] ) ) {
    		$menu = wp_get_nav_menu_object( $locations[ $menu_name ] );
    	
    		$menu_items = wp_get_nav_menu_items($menu->term_id);
    
    		foreach ( (array) $menu_items as $key => $menu_item ) {
    			if($menu_item->object_id == $id) {
    				$title = $menu_item->title;
    				$url = $menu_item->url;
    			}
    		}
    	}
    	
    	if(is_page()) {
    		$home = $trail[0];
    		$page = $trail[1];
            $last = $title;
    		$trail = array(0 => $home, 1 => $page, 'trail_end' => $last);
    	}
        
    	return $trail;
    }

    To change the sidebar menu, disable the Page Sidebar navigation on Enfold > Sidebar Settings. Replace it with a Custom Menu.

    Cheers!
    Ismael

    #415769

    Hi Ismael,

    Thanks for your answer!

    But I have put your code in child’s functions.php, and the last part of the breadcrumb shows always the same menu-id, plus sometimes the middle part of the breadcrumb is blank.

    I have cleared the cache and try again, but the result is the same.

    Is there something wrong in the code? Or do I have to do anything else?

    Thanks again!
    Rosa.

    #416392

    Hi!

    Yes, there’s something wrong with the code. My bad. We modified the code above, please try it.

    Regards,
    Ismael

    #416611

    Hi Ismael,
    I appreciate your help! Sorry I cannot help with the code (I know a few about that..). Now the code is better but breadcrumbs are not completely OK…

    This is the scenario example:
    Inicio/Cursos in Company/Ventas/Técnicas de Ventas (Pages Hierarchy)
    Inicio/Programas /Ventas/Técnicas de Ventas (Menú items Hierarchy)

    If I click “Programas” 1st level menú—-> breadcrumb shows “Inicio//Programas” (error: double slash with empty content)
    Breadcrumb should be “Inicio/Programas”

    If I click “Ventas” 2nd level menú —-> breadcrumb shows “Inicio/Cursos in Company/Ventas” (error: 1st level should be Menu id, no Title).
    Breadcrumb should be “Inicio/Programas/Ventas”

    If I click “Técnicas de Ventas” 3rd level menú—> breadcrumb shows “Inicio/Cursos in Company/ Técnicas de Venta” (error: 2nd level menu doesn’t show in breadcrumb). Breadcrumb should be “Inicio/Programas/Ventas/Técnicas de Venta”

    Thanks again for your help!

    Regards,
    Rosa

    #416624

    This is a great idea and I added the following to my functions.php however I am getting two // in the breadcrumbs (You are here: Home / / Rehabilitation).

    add_filter(‘avia_breadcrumbs_trail’, ‘avia_change_breadcrumb’, 20, 1);
    function avia_change_breadcrumb($trail) {
    $menu_name = ‘avia’;
    $id = get_the_ID();

    if ( ( $locations = get_nav_menu_locations() ) && isset( $locations[ $menu_name ] ) ) {
    $menu = wp_get_nav_menu_object( $locations[ $menu_name ] );

    $menu_items = wp_get_nav_menu_items($menu->term_id);

    foreach ( (array) $menu_items as $key => $menu_item ) {
    if($menu_item->object_id == $id) {
    $title = $menu_item->title;
    $url = $menu_item->url;
    }
    }
    }

    if(is_page()) {
    $home = $trail[0];
    $page = $trail[1];
    $last = $title;
    $trail = array(0 => $home, 1 => $page, ‘trail_end’ => $last);
    }

    return $trail;
    }

    #416650
    This reply has been marked as private.
    #417579

    Hey!

    Hmm.. Ok.. If this doesn’t work, I’ll ask the rest of the support team to provide another solution:

    add_filter('avia_breadcrumbs_trail', 'avia_change_breadcrumb', 20, 1);
    function avia_change_breadcrumb($trail) {
    	$menu_name = 'avia';
    	$id = get_the_ID();
    	
        if ( ( $locations = get_nav_menu_locations() ) && isset( $locations[ $menu_name ] ) ) {
    		$menu = wp_get_nav_menu_object( $locations[ $menu_name ] );
    	
    		$menu_items = wp_get_nav_menu_items($menu->term_id);
    
    		foreach ( (array) $menu_items as $key => $menu_item ) {
    			if($menu_item->object_id == $id) {
    				$title = $menu_item->title;
    				$url = $menu_item->url;
    			}
    		}
    	}
    	
    	if(is_page()) {
    		$home = $trail[0];	
            $last = $title;
    		if(isset($trail[1])) {
    		$page = $trail[1];
    		$trail = array(0 => $home, 1 => $page, 'trail_end' => $last);
    		} else {
    		$trail = array(0 => $home, 'trail_end' => $last);	
    		}
    	}
        
    	return $trail;
    }

    Regards,
    Ismael

    #418027

    Hi Ismael,

    Thanks for your efforts!
    I put your code in child’s functions.php and isn’t still working well. You can check it.
    When I click in a last level menu, breadcrumb doesn’t show the previous level, plus in some levels Title still appears instead of Menu ID.,

    I appreciate your help and new suggestions.

    Best regards,
    Rosa

    #418200

    That worked. Thank you!

    #419267

    Hey!

    @blanchrosa: The purpose of the code above is to show the name of the current menu item for the current page. It doesn’t have any hierarchy feature. If you want to create that kind of breadcrumb, you will have to hire a freelance developer or you can request the feature here: https://kriesi.at/support/enfold-feature-requests/

    Cheers!
    Ismael

    #466828

    Thanks Ismael!
    Finally I solved it using Yoast breadcrumbs. They allow to set your own name for every part of the breadcrumb.

    Best regards
    Rosa

    #466835

    Hi!

    Happy you got a solution.
    I will close the ticket now, and let us know if we could do anything else for you.

    Regards,
    Basilis

Viewing 17 posts - 1 through 17 (of 17 total)

The topic ‘How Sidebar Navigation and Breadcrumbs could show Menu item instead of Title?’ is closed to new replies.