我正在处理一个子主题,我需要重写一个函数,以便删除顶部菜单上一些不需要的项目。所以我做了一些研究,发现了很多文档,真的,像this, this 和this 但我仍然不清楚如何在我的具体案例中实现这一点。所以我希望这里有人能给我指出正确的方向。我在原始主题中有此功能functions.php
文件:
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;
}
我想,它被称为:
// 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);
我需要重写的是从
udesign_nav_fallback()
功能:
$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>\';
使用
functions.php
关于儿童主题?