Answers for "advanced custom fields image url with terms"

PHP
1

retrive acf from taxonomy

<?php // ACF in Taxonomy

// get the current taxonomy term
$term = get_queried_object();


// vars
$image = get_field('image', $term);
$color = get_field('color', $term);

?>
<style type="text/css">
	
	.entry-title a {
		color: <?php echo $color; ?>;
	}
	
	<?php if( $image ): ?>
	.site-header {
		background-image: url(<?php echo $image['url']; ?>);
	}
	<?php endif; ?>
	
</style>
<div class="wrap">
	
	<?php // Remaining template removed from example ?>
Posted by: Guest on May-13-2020
0

acf show the taxonomy image

<?php
    $terms = get_the_terms( get_the_ID(), 'product_brands' );

       if( ! empty( $terms ) ) : ?>
           <ul>	
		<?php foreach( $terms as $term ) : ?>
						    	 
		 <li class="<?php echo $term->slug; ?>">
															
                    <img src="<?php the_field('brand_logo', $term); ?>" />
		  
                 </li>

  <?php endforeach; ?>
          </ul> 
<?php
   endif;
?>
Posted by: Guest on November-18-2020

Code answers related to "advanced custom fields image url with terms"

Browse Popular Code Answers by Language