Skip to content

Instantly share code, notes, and snippets.

@ChrisCree
Created September 13, 2012 22:59
Show Gist options
  • Save ChrisCree/3718386 to your computer and use it in GitHub Desktop.
Save ChrisCree/3718386 to your computer and use it in GitHub Desktop.
<?php
// Add for Taxonomies
function wsm_add_for_taxonomies( $display, $meta_box, $taxonomy ) {
if ( 'taxonomy' !== $meta_box['show_on']['key'] )
return $display;
// Get the post's ID so we can see if it has ancestors
if( isset( $_GET['post'] ) ) $post_id = $_GET['post'];
elseif( isset( $_POST['post_ID'] ) ) $post_id = $_POST['post_ID'];
if( !isset( $post_id ) )
return false;
// If the post is a taxonomy, show the box
$tax = get_term( $post_id, $taxonomy );
$slug = $term->slug;
if( '' != $slug )
return true;
// Otherwise, it's not taxonomy, so don't show it
else
return false;
}
add_filter( 'cmb_show_on', array( &$this, 'wsm_add_for_taxonomies' ), 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment