在Mobile菜单中手动添加了Link缺失

时间:2016-10-18 14:02:46

标签: php wordpress add-filter

我使用“wp_nav_menu_items”挂钩添加了指向我的WordPress菜单的链接。它在普通的宽屏菜单中运行良好,但它不会显示在移动下拉菜单中。我需要一个不同的钩子吗?

这是我的代码(在我的主题Functions.php文件中):

add_filter( 'wp_nav_menu_items', 'custom_menu_item', 10, 2 );
function custom_menu_item ( $items, $args ) {

    $url = ThemexUser::$data['user']['profile_url'];
    if ( is_user_logged_in() && $args->theme_location == 'main_menu' ) {
        $items .= '<li class="menu-item"><a href="'.$url.'">My Profile</a></li>';
    }
    return $items;

}

一些视觉效果,只是为了清楚:
Normal Menu (Added link appears)
Mobile Menu (Added link is missing)

我希望“我的个人资料”链接也会显示在移动设备菜单中。使用的主题是LoveStory By Themex(版本1.15),它已经完全由自定义的儿童主题重新设计。

任何指导都将不胜感激。

0 个答案:

没有答案