Open TheNewGuy16 opened 7 years ago
Hello,
Us term_id instead of get_the_ID()
e.g,
<?php $terms = get_terms( array( 'taxonomy' => 'collection_category', 'hide_empty' => false, ) ); foreach($terms as $term) { echo (get_term_meta( $term->term_id, '_cmb2_taxonomy_collection_banner', true )); }?>
Hello, Us term_id instead of get_the_ID() e.g,
<?php $terms = get_terms( array( 'taxonomy' => 'collection_category', 'hide_empty' => false, ) ); foreach($terms as $term) { echo (get_term_meta( $term->term_id, '_cmb2_taxonomy_collection_banner', true )); }?>
@irfandeveloper Thank you. The exact code he's been looking for for a long time. But it lists all metabox values. I just want the corresponding value to be taken. So let it be taken separately. How can I do it?
Hey having trouble getting the image to show up on the front end using cmb2 taxonomy. I have used regular cmb2 for other stuff and it works great. I have a custom taxonomy for a custom post type and i need to get the image of the taxonomy and display it as a banner for each of my post types. but its not coming up. Its saving to the DB but not getting displayed on the front end when i use
`add_filter('cmb2-taxonomy_meta_boxes', 'cmb2_taxonomy_metaboxes');
/**
@return array */ function cmb2_taxonomy_metaboxes( array $meta_boxes ) {
// Start with an underscore to hide fields from custom fields list $prefix = '_cmb2taxonomy';
/**
return $meta_boxes; }` that saves the meta box and it is saving to the db then to display it i have
$bannerImg = get_term_meta(get_the_ID(), '_cmb2_taxonomy_collection_banner',true);?>
<div class="col-xs-12 banner-image" style="background-image: url('<?php echo $bannerImg?>');"></div>
but don't see it on the front end.I see you refer to the basic usage for cmb2 but none of that is working. So can you give me an example of how to add an image field and display that image on the front end using cmb2 taxonomy?