New Landing How can we help? Themeforest Theme Support Dante How to hide/deregister Custom Post Types

Viewing 10 posts - 1 through 10 (of 10 total)
  • Posted in: Dante
  • #165750
    alemarengo
    Member
    Post count: 695

    Hi guys!
    I’ve found this topic on Neighborhood in which it is suggested to use the following snippet:

    /*------------------------------------------*/
    /* Remove Unwanted Admin Menu Items */
    /*------------------------------------------*/
    
    function remove_admin_menu_items() {
        $remove_menu_items = array(__('Jobs'),__('Portfolio'));
        global $menu;
        end ($menu);
        while (prev($menu)){
            $item = explode(' ',$menu[key($menu)][0]);
            if(in_array($item[0] != NULL?$item[0]:"" , $remove_menu_items)){
            unset($menu[key($menu)]);}
        }
    }
    
    add_action('admin_menu', 'remove_admin_menu_items');

    Since I need to get rid of Jobs, Portfolio, Galleries, Team & Testimonials, I think it will be enough for me to add them to $remove_menu_items, right?
    Should I use __('xxx') syntax?

    Can you please confirm that to me?

    #165785
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    Please add item to $remove_menu_items and you dont need to use this syntax __(‘xxx’).
    Thanks
    Mohammad

    #165790
    alemarengo
    Member
    Post count: 695

    Hi Mohammad,
    I added this to functions.php:

    function remove_admin_menu_items() {
        $remove_menu_items = array('jobs','portfolio','galleries','team','testimonials', 'faqs');
        global $menu;
        end ($menu);
        while (prev($menu)){
            $item = explode(' ',$menu[key($menu)][0]);
            if(in_array($item[0] != NULL?$item[0]:"" , $remove_menu_items)){
            unset($menu[key($menu)]);}
        }
    }
    
    add_action('admin_menu', 'remove_admin_menu_items');

    Nothing happened. ๐Ÿ™

    #165795
    Mohammad – SUPPORT
    Moderator
    Post count: 27441

    Hi,
    Please use __(‘xxx’) syntax.
    Thanks
    Mohammad

    #166159
    alemarengo
    Member
    Post count: 695

    Ok, that way works! Great, thanks!

    #166162
    Rui Guerreiro – SUPPORT
    Keymaster
    Post count: 25779

    Great. Thanks Mohammad.
    -Rui

    #168475
    alemarengo
    Member
    Post count: 695

    Hi guys,
    after adding your snippet to my website, plesk reported me an error like this:

    [warn] [client 151.51.175.112] mod_fcgid: stderr: PHP Warning: Invalid argument supplied for foreach() in /var/www/vhosts/xxx/httpdocs/wp-admin/includes/plugin.php on line 1419

    which refers to this function:

    function remove_menu_page( $menu_slug ) {
    	global $menu;
    
    	foreach ( $menu as $i => $item ) {
    		if ( $menu_slug == $item[2] ) {
    			unset( $menu[$i] );
    			return $item;
    		}
    	}
    
    	return false;
    }

    How could I fix this?

    Sorry, my fault! Plesk error refers to another snippet involving Jetpack… ๐Ÿ™

    #168695
    Rui Guerreiro – SUPPORT
    Keymaster
    Post count: 25779

    Hi,

    Didn’t understand, the code you posted is from our theme or Jetpack?
    If it’s Jetpack we can’t assist.

    -Rui

    #169193
    alemarengo
    Member
    Post count: 695

    Sorry guys! I wanted to delete all the text, including the snippet, because it wasn’t it causing that error, but another snippet. ๐Ÿ™‚

    Deregister with the above snippet is super fine and working like a charm!

    #169219
    Rui Guerreiro – SUPPORT
    Keymaster
    Post count: 25779

    Ok. Glad it’s sorted.
    -Rui

Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register