Tagged: breadcrumbs, menu-item
-
AuthorPosts
-
March 18, 2015 at 12:28 pm #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
OpinionsBut 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!
March 19, 2015 at 5:33 pm #414668March 19, 2015 at 7:32 pm #414776This reply has been marked as private.March 19, 2015 at 7:45 pm #414786Hey!
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,
YigitMarch 19, 2015 at 8:39 pm #414818This reply has been marked as private.March 21, 2015 at 6:04 am #415644Hi!
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!
IsmaelMarch 21, 2015 at 6:43 pm #415769Hi 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.March 23, 2015 at 3:13 pm #416392Hi!
Yes, there’s something wrong with the code. My bad. We modified the code above, please try it.
Regards,
IsmaelMarch 23, 2015 at 7:33 pm #416611Hi 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,
RosaMarch 23, 2015 at 7:48 pm #416624This 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;
}March 23, 2015 at 8:17 pm #416650This reply has been marked as private.March 25, 2015 at 7:49 am #417579Hey!
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,
IsmaelMarch 25, 2015 at 6:12 pm #418027Hi 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,
RosaMarch 25, 2015 at 11:14 pm #418200That worked. Thank you!
March 27, 2015 at 2:09 pm #419267Hey!
@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!
IsmaelJuly 1, 2015 at 9:01 am #466828Thanks Ismael!
Finally I solved it using Yoast breadcrumbs. They allow to set your own name for every part of the breadcrumb.Best regards
RosaJuly 1, 2015 at 9:10 am #466835Hi!
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 -
AuthorPosts
- The topic ‘How Sidebar Navigation and Breadcrumbs could show Menu item instead of Title?’ is closed to new replies.