how to hide a menu entry in wordpress

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

b/Wordpress code published by. u/mkmcst Jul 30, 2026, 10:27 PM
add_filter('wp_nav_menu_objects', 'mkmcst_hide_manage_menu_item', 10, 2);

function mkmcst_hide_manage_menu_item($items, $args) {
    if (!is_user_logged_in()) {
        foreach ($items as $key => $item) {
            // Target the 'manage' link by URL
            if ($item->url == 'https://plimothtoday.com/manage/') {
                unset($items[$key]);
            }
        }
    }
    return $items;
}
Please log in or create an account to leave a comment or to download
u/mkmcst Jul 30, 2026, 10:29 PM
make sure to change the  https://plimothtoday.com/manage/  to the url to the menu tab your trying to hide
Start a Discussion

b/Wordpress code

Reference and examples of PHP, HTML, CSS, and JavaScript code used to customize and develop WordPress websites.

4
Topics
Explore Board