I'm working in a child theme and I need to override a function in order to remove some unwanted items on a top menu. So I have research a bit and found a lot of docs, really, like this, this and this among others but still not clear at all to me how to achieve this on my specific case. So I hope someone here can point me on the right direction. I have this functions at original theme functions.php
file:
function udesign_nav() {
if ( function_exists( 'wp_nav_menu' ) ) {
$defaults = array(
'container_class' => 'navigation-menu',
'container_id' => 'navigation-menu',
'menu_id' => 'main-top-menu',
'menu_class' => 'sf-menu',
'link_before'=> '<span>',
'link_after' => '</span>',
'theme_location' => 'primary',
'fallback_cb' => 'udesign_nav_fallback'
);
wp_nav_menu( $defaults );
} else {
udesign_nav_fallback();
}
}
function udesign_nav_fallback() {
$menu_html = '<div id="navigation-menu" class="navigation-menu">';
$menu_html .= '<ul id="main-top-menu" class="sf-menu">';
$menu_html .= is_front_page() ? "<li class='current_page_item'>" : "<li>";
$menu_html .= '<a href="'.home_url().'"><span>'.esc_html__('Home', 'udesign').'</span></a></li>';
$menu_html .= wp_list_pages('depth=5&title_li=0&sort_column=menu_order&link_before=<span>&link_after=</span>&echo=0');
$menu_html .= '</ul>';
$menu_html .= '</div>';
echo $menu_html;
}
And it is called, I think, here:
// Setup the main menu
function udesign_top_main_menu() {
ob_start(); ?>
<div class="clear"></div>
<div id="main-menu">
<div id="dropdown-holder" class="container_24">
<?php udesign_nav(); // this function calls the main menu ?>
</div>
<!-- end dropdown-holder -->
</div>
<!-- end top-main-menu -->
<?php
$main_menu_html = ob_get_clean();
echo apply_filters( 'udesign_get_top_main_menu', $main_menu_html );
}
add_action('udesign_top_wrapper_bottom', 'udesign_top_main_menu', 10);
What I need to override is just remove this two lines from udesign_nav_fallback()
function:
$menu_html .= is_front_page() ? "<li class='current_page_item'>" : "<li>";
$menu_html .= '<a href="'.home_url().'"><span>'.esc_html__('Home', 'udesign').'</span></a></li>';
What I need to do in order to achieve that using the functions.php
on the child theme?