Created
September 13, 2012 22:59
-
-
Save ChrisCree/3718386 to your computer and use it in GitHub Desktop.
Add metabox to WordPress taxonomies via https://github.com/jaredatch/Custom-Metaboxes-and-Fields-for-WordPress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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