Last active
July 26, 2016 15:35
-
-
Save schoenwaldnils/00a544e35a6917cec7cc9602c2397c4c to your computer and use it in GitHub Desktop.
Create array for custom taxonomies
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
function array_post_taxonomies($the_id) { | |
$content = []; | |
$args = array( 'public' => true, '_builtin' => false ); | |
$output = 'objects'; | |
$operator = 'and'; | |
$taxonomies = get_taxonomies( $args, $output, $operator ); | |
if( $taxonomies ) { | |
foreach( $taxonomies as $taxonomy ) { | |
$terms = wp_get_post_terms($the_id, $taxonomy->name); | |
$term = $terms[0]->name; | |
if (!empty($terms)) { | |
$content[] = array( | |
'title' => $taxonomy->labels->singular_name, | |
'term' => $term | |
); | |
} | |
} | |
} | |
return $content; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment