my site has 3 custom post types that each post type has a unique custom taxonomy to that post type.
I want to display these taxonomies in my single posts page and just the taxonomy related to that post type and not the others and without categories and tags.
setting the _builtin to false would do the trick for categories and tags but I can't figure out the way to display those custom taxonomies properly and my posts page show all custom taxonomies from all post types.
I don't know php perfectly and tried to find the code from multiple sites including this site and this is my code so far:
// get taxonomies terms links
function custom_taxonomies_terms_links() {
global $post, $post_id;
// get post by post id
$post = &get_post($post->ID);
// get post type by post
$post_type = $post->post_type;
// get post type taxonomies
$args = array(
'public' => true,
'_builtin' => false
);
$output = 'names'; // or objects
$operator = 'and'; // 'and' or 'or'
$taxonomies = get_taxonomies( $args, $output, $operator );
$out = "<ul>";
foreach ($taxonomies as $taxonomy) {
$out .= "<li>".$taxonomy.": ";
// get the terms related to post
$terms = get_the_terms( $post->ID, $taxonomy );
if ( !empty( $terms ) ) {
foreach ( $terms as $term )
$out .= '<a href="' .get_term_link($term->slug, $taxonomy) .'">'.$term->name.'</a> ';
}
$out .= "</li>";
}
$out .= "</ul>";
return $out;
}
any help will be appreciated.tnx