Created
August 19, 2013 20:04
-
-
Save hchouhan/6273438 to your computer and use it in GitHub Desktop.
Get Link to just 1 category in which the current post/product is in.
dot_browse_product_cat()
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 taxonomies terms links | |
function dot_browse_product_cat() { | |
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 | |
$taxonomies = get_object_taxonomies($post_type); | |
foreach ($taxonomies as $taxonomy) { | |
// get the terms related to post | |
$terms = get_the_terms( $post->ID, $taxonomy ); | |
if ( !empty( $terms ) ) { | |
$out = array(); | |
foreach ( $terms as $term ) | |
$out[] = '<a class="browse" href="' .get_term_link($term->slug, $taxonomy) .'"><i class="icon-th-large"></i> Browse '.$term->name.'</a>'; | |
//$return = join( ', ', $out ); | |
$return = $out[0]; | |
} | |
} | |
return $return; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment