Skip to content

Instantly share code, notes, and snippets.

@martynchamberlin
Last active December 23, 2015 00:59
Show Gist options
  • Save martynchamberlin/6557268 to your computer and use it in GitHub Desktop.
Save martynchamberlin/6557268 to your computer and use it in GitHub Desktop.
I highly recommend the Query Multiple Taxonomies (http://scribu.net/wordpress/query-multiple-taxonomies/) plugin. It lets you build custom post types and custom taxonomies. But what if you are in a WordPress post type and want to print that a taxonomy of that post to the screen? "Stupid idea!" You say. "I specify that post's taxonomies within th…
<?php
function z_get_taxonomy( $var )
{
extract( shortcode_atts( array(
'name' => ''
), $var ) );
$postID = get_the_ID();
if ( ! empty( $name ) )
{
$taxonomy = wp_get_post_terms( $postID, $name );
if ( ! empty( $taxonomy ) )
{
$taxonomy = $taxonomy[0];
$taxonomy = $taxonomy->name;
return $taxonomy;
}
}
return "";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment