WordPress NextGen Remove “Set NextGEN Featured Image” From Edit Page

I’m using NextGen for some galleries and noticed that since loading this plugin, in the edit page area under the Featured Image Meta box there is now a link to “Set NextGEN Featured Image”. I don’t want to confuse the user (by having two “set featured image” links, so I’d like to remove the NextGEN option, leaving only the one default WP link to set the featured image.

I’ve found tutorials on how to change the text of the standard WordPress “Set Featured Image” Meta Box, but nothing on how to remove the NextGEN link, (I did find a post for adding a plugin to remove it: http://wordpress.org/support/topic/remove-set-nextgen-featured-image)

Read More

However, I would like to just remove it in my functions.php file (not use a plugin).

I’ve tried the following in my functions.php file:

remove_meta_box
remove_filter
remove_action

But I’m not 100% sure which I need to use (none have worked so far).

The file that is adding this function to the page edit area is: https://github.com/mneuhaus/foo/blob/master/nextgen-gallery/products/photocrati_nextgen/modules/ngglegacy/lib/post-thumbnail.php.

I realize that I would just comment out the text in this file that produces the link, but if I ever updated the plugin it would be overwritten.

Any help or suggestions are greatly appreciated! Thank you.

Related posts

Leave a Reply

1 comment

  1. If you don’t have/need anything customized for the Featured Image meta box, you can simply remove all filters:

    function so_23984689_remove_nextgen_post_thumbnail_html() {
    
        remove_all_filters( 'admin_post_thumbnail_html' );
    }
    
    add_action( 'do_meta_boxes', 'so_23984689_remove_nextgen_post_thumbnail_html' );
    

    If there are any other filters, which you would want to keep, you have to loop through the filter array and remove the according element:

    function so_23984689_remove_nextgen_post_thumbnail_html() {
    
        global $wp_filter;
    
        if ( ! isset( $wp_filter[ 'admin_post_thumbnail_html' ] ) ) {
            return;
        }
    
        foreach ( $wp_filter[ 'admin_post_thumbnail_html' ] as $priority => $filters ) {
            foreach ( $filters as $id => $filter ) {
                if (
                    isset( $filter[ 'function' ] )
                    && is_object( $filter[ 'function' ][ 0 ] )
                    && $filter[ 'function' ][ 0 ] instanceof nggPostThumbnail
                ) {
                    unset( $wp_filter[ 'admin_post_thumbnail_html' ][ $priority ][ $id ] );
                }
            }
        }
    }
    
    add_action( 'do_meta_boxes', 'so_23984689_remove_nextgen_post_thumbnail_html' );