2013-05-11 70 views
1

我想通过插件文件中的钩子在模板navbar部分中添加菜单项/页面链接。我不要使用任何插件this.I想使用谷歌搜索hook.I后曾尝试那些:如何在模板头navbar菜单部分通过钩子添加页面链接/菜单项wordpress

add_action('wp_header', ' xx_add_to_header'); 
function xx_add_to_header() { 


echo "<li><a href='king.php'>DDD</a> </li>"; 
    } 

还有一句:

add_filter('wp_nav_menu_items', 'your_custom_menu_item', 10, 2); 
    your_custom_menu_item ($items, $args) { 
    if (is_single() && $args->theme_location == 'primary') { 
    $items .= '<li><a href='king.php'>DDD</a></li>'; 
    } 
    return $items;  
    } 

其没有work.What是做正确的方式这个????
在此先感谢

回答

1

我认为短代码将解决我的问题。我是新的wordpress.I不知道wordpress的短代码。