jcchavezs / cmb2-taxonomy

Custom metaboxes for taxonomies
GNU General Public License v2.0
34 stars 8 forks source link

Image filed for taxonomy not shwing on front end #15

Open TheNewGuy16 opened 7 years ago

TheNewGuy16 commented 7 years ago

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');

/**

$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?

irfandeveloper commented 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 )); }?>

mehmetsarr commented 4 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 )); }?>

@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?