Enabling/Disabling meta boxes of Genesis Widget Generator Plugin

By default Plugin is adding the meta boxes for page and post. But you can enable / disable the meta boxes using filters. GWG have a filter “gwg_support_post_types”. Using this filter you can add the meta box in you CPT’s or remove from existing post type.

Removing the meta boxes for Post

Add the following code in your functions.php file. Here is the snippet:

/**
 * Removing GWG metaboxes for Post type
 */
add_filter( 'gwg_support_post_types', 'gd_remove_gwg_post_metabox' );
function gd_remove_gwg_post_metabox( $post_types ) {

   $post_types = array('page');
   return $post_types;

}

remove-metabox-for-post-type

Add the meta boxes at Custom Post Type

Assume you have “product” post type. Then you will add following script in your functions.php file:

/**
 * Adding GWG metaboxes for "product" post type
 */
add_filter( 'gwg_support_post_types', 'gd_remove_gwg_post_metabox' );
function gd_remove_gwg_post_metabox( $post_types ) {

   $post_types[] = "product";
   return $post_types;

}

If you have multiple post types like “portfolio”, “products”, “books” then you will try this code:

/**
 * Adding GWG metaboxes into multiple post types
 *
 * Meta boxes will appear for "page", "post", "portfolio", "products", "books"
 */
add_filter( 'gwg_support_post_types', 'gd_remove_gwg_post_metabox' );
function gd_remove_gwg_post_metabox( $post_types ) {

   $post_types = array_merge( $post_types, array( "portfolio", "products", "books" ) );
   return $post_types;

}

Share This Article

Subscribe Membership Plan ($9.99/mo)

  • Get full access to all premium tutorials
  • Get Support for the posted content
  • Request for specific how-to tutorials
  • Cancel the subscription at anytime

Reader Interactions

Leave A Reply

Your email address will not be published. Required fields are marked *