Last active
December 23, 2015 00:59
-
-
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…
This file contains 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 | |
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