php - Custom Static Links For Specific Menu Right Before/Next The wp_nav_menu Function? -
i trying add custom links next/before wp built in menu, main_menu . have placed in functions.php , give (li)'s in nav-menu-after.php , before file, it's not working.
add_filter('wp_nav_menu_items',do_wp_nav_menu_items); function do_wp_nav_menu_items($menu, $args=array()) { if( file_exists( templatepath . '/nav-menu-before.php' ) && $args->theme_location == 'main_menu' ) { ob_start(); @include templatepath . '/nav-menu-before.php'; $nav_menu_before = ob_get_clean(); } if( file_exists( templatepath . '/nav-menu-after.php' ) && $args->theme_location == 'main_menu' ) { ob_start(); @include templatepath . '/nav-menu-after.php'; $nav_menu_after = ob_get_clean(); } return $nav_menu_before . $menu . $nav_menu_after; }
if delete part
&& $args->theme_location == 'main_menu'
it's working custom static links appear in whole menu have. not main_menu.
i new coding. suggestion appreciated. thanks!
Comments
Post a Comment