| 1 |
<?php |
| 2 |
if (!function_exists('blockspare_get_cat_tax_tags')) { |
| 3 |
function blockspare_get_cat_tax_tags($taxType, $post_id, $post_type = '') |
| 4 |
{ |
| 5 |
|
| 6 |
|
| 7 |
if ('post' == $post_type) { |
| 8 |
|
| 9 |
if($taxType == 'category' || $taxType == ''){ |
| 10 |
$categories_list = get_the_category_list(' ', '', $post_id); |
| 11 |
if ($categories_list) { |
| 12 |
/* translators: 1: list of categories. */ |
| 13 |
printf(esc_html__('%1$s', 'blockspare'), $categories_list); // WPCS: XSS OK. |
| 14 |
} |
| 15 |
} |
| 16 |
else if($taxType == 'post_tag' ){ |
| 17 |
$taxonomy = $taxType; // this is the name of the taxonomy |
| 18 |
|
| 19 |
$terms = get_the_terms($post_id,$taxonomy); |
| 20 |
|
| 21 |
if($terms){ |
| 22 |
foreach ( $terms as $term_item ) {?> |
| 23 |
<a href="" class="category tag" ><?php echo $term_item->name; ?></a> |
| 24 |
<?php } |
| 25 |
|
| 26 |
} |
| 27 |
}else{ |
| 28 |
$taxonomy = $taxType; |
| 29 |
$terms = get_the_terms($post_id,$taxonomy); |
| 30 |
|
| 31 |
if($terms){ |
| 32 |
foreach ( $terms as $term_item ) {?> |
| 33 |
<a href="" class="category tag" ><?php echo $term_item->name; ?></a> |
| 34 |
<?php } |
| 35 |
|
| 36 |
} |
| 37 |
} |
| 38 |
} else { |
| 39 |
|
| 40 |
$taxonomies = get_object_taxonomies($post_type, 'objects'); |
| 41 |
|
| 42 |
|
| 43 |
foreach ($taxonomies as $term_slug => $terms) { |
| 44 |
if (!$terms->public || !$terms->show_ui) { |
| 45 |
continue; |
| 46 |
} |
| 47 |
$terms = get_the_terms($post_id, $term_slug); |
| 48 |
if ($terms) { |
| 49 |
foreach ($terms as $term_key => $term_item) { ?> |
| 50 |
<a href="" class="category tag"><?php echo $term_item->name; ?></a> |
| 51 |
<?php } |
| 52 |
} |
| 53 |
} |
| 54 |
} |
| 55 |
} |
| 56 |
} |
| 57 |
|