WordPress remove capability post ,media completely for custom role

Remove a top level admin menu:

    function custom_menu_page_removing() {
    remove_menu_page( $menu_slug );
}
add_action( 'admin_menu', 'custom_menu_page_removing' );

To remove only certain menu items include only those you want to hide within the function.
To remove menus for only certain users you may want to utilize current_user_can().

You can take a look at https://codex.wordpress.org/Function_Reference/remove_menu_page