Created
June 16, 2016 14:39
-
-
Save kellenmace/0ce334f036f19c677b9e0cd0682b9ca4 to your computer and use it in GitHub Desktop.
Get Post Types by Taxonomy in WordPress
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 | |
/** | |
* Get all post types for a taxonomy. | |
* | |
* @author Kellen Mace | |
* @param string $taxonomy The taxonomy slug to get post types for. | |
* @return array The post types associated with $taxonomy. | |
*/ | |
function wds_campbell_get_post_types_by_taxonomy( $taxonomy = '' ) { | |
global $wp_taxonomies; | |
if ( isset( $wp_taxonomies[ $taxonomy ] ) ) { | |
return $wp_taxonomies[ $taxonomy ]->object_type; | |
} | |
return array(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment