0

I installed a plugin that has a custom post type, that looks like the picture below:

enter image description here

WhatI's like to do is hide the "Pictures" link in this menu. It's a custom post type. The link looks like: edit.php?post_type=cbs_pictures

I tried:

function plt_hide_custom_post_type_ui_menus() {
    remove_submenu_page('menu-posts-cbs_booking', 'edit.php?post_type=cbs_pictures');
}
add_action('admin_menu', 'plt_hide_custom_post_type_ui_menus', 11);

I also tried:

function your_custom__remove_menu_items() {
    remove_menu_page( 'edit.php?post_type=cbs_pictures' );
}
add_action( 'admin_menu', 'your_custom_remove_menu_items' );

but neither of these snippets worked...the "Pictures" link still shows.

Anyone know how this could be hidden? I would like to still be able to use the url to access the page, I would just like the "Pictures" menu item to be hidden. Any ideas?

Thanks,
Josh

2 Answers 2

0

Those methods that you were using, remove the page totally. If you were the plugin author I would suggest to create the admin page calling add_submenu_page with a parent id of null. Since you can't change the plugin code the only way to achieve this is using CSS.

Read this ticket for more information about the problem.

0

So, I put this in my functions file, which successfully hid my menu item :-) Thanks @Had1z for the suggestion!

add_action('admin_head', 'custom_style');

function custom_style() {
    echo '<style>
        #menu-posts-cbs_booking .wp-submenu li:nth-child(6) {
            display: none;
        }
    </style>';
}

Hope this helps someone, marking @Had1z's answer as the correct one since it steered me in the right direction :-)

Thanks,
Josh

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.