Filter: Add MD Meta Boxes to Custom Post Types

These filters are included in the MD Child Theme by default and can be used to add any active MD meta boxes to the post editor screen of custom post types and taxonomies.

This includes Featured Image controls, Layout Options, Popups, and other meta boxes added to MD out of the box (and not disabled with the Features Manager).

/**
 * Add MD meta options to any Custom Post Type.
 */

function md_add_post_type_meta( $post_type ) {
	$post_type[] = 'download';

	return $post_type;
}

add_filter( 'md_post_type_meta', 'md_add_post_type_meta' );


/**
 * Add MD meta options to any Custom Taxonomy.
 */

function md_add_taxonomy_meta( $taxonomy ) {
	$taxonomy[] = 'download_category';
	$taxonomy[] = 'product_cat';

	return $taxonomy;
}

add_filter( 'md_taxonomy_meta', 'md_add_taxonomy_meta' );

To use the filters, all that’s needed is the ID of the post type or taxonomy and plugging them into their respective filters.

To find the ID of a Custom Post Type (CPT), click through to the main screen and look in your browser’s address bar to find a URL with the post_type attribute set, like so:

https://domain.com/wp-admin/edit.php?post_type=download
MD Custom Post Types

Click for a larger size

…the process for finding any custom Taxonomy is the same, simply click through to any Custom Post Types “category” pages and grab the taxonomy ID from the URL:

MD Custom Taxonomy

Click for larger view

Leave a Comment