Only outputting custom field in first foreach loop.
-
Hi,
I’m using this plugin to place an image field on the a custom taxonomy called ‘base_location’.
I’m then looping through all of the taxonomies and pulling the images along with them.
Here’s my code:<?php // List of Provinces $provinces = get_terms( 'base_location', array( 'parent' => 0 )); echo '<div id="where-to-go-provinces" class="clearfix">'; foreach ($provinces as $province) { // Get custom field image for each term $cat_image = get_category_meta('image', $province); ?> <div class="province threecol"> <a href="<?php echo get_term_link($province); ?>"> <?php echo wp_get_attachment_image($cat_image, 'place-thumbnail'); ?> <?php echo '<h3>' . $province->name . '</h3>'; ?> </a> </div> <?php } echo '</div>'; ?>
The problem is, it’s only returning the image from the custom field for the very first
foreach
. After this, it doesn’t output anything.Here’s a screenshot to show what I mean: https://cl.ly/image/0X3b2f3f2h3o
Do you know why this might be?
https://www.ads-software.com/plugins/cfs-custom-category-fields/
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Only outputting custom field in first foreach loop.’ is closed to new replies.