وردپرس
Problem in Getting Thumbnail Image
I am developing a custom theme and trying to loop out all the brands in a custom layout which have brand’s name and thumbnail image. The names are coming correctly but I cannot loop out the thumbnail images can some one guide me through it. This is the wp_query I am using
<?php
$brand_terms = get_terms(array(
'taxonomy' => 'berocket_brand', // Replace with your custom brand taxonomy
'hide_empty' => false, // Show even if there are no products assigned
));
if (!empty($brand_terms)) {
foreach ($brand_terms as $brand_term) {
$brand_name = $brand_term->name;
$brand_link = get_term_link($brand_term);
// Get the brand image associated with the current brand term
$brand_image = get_term_meta($brand_term->term_id, 'brand_image', true);
?>
<div class="brand-item">
<h2><a href="https://wordpress.org/support/topic/problem-in-getting-thumbnail-image/<?php echo esc_url($brand_link); ?>"><?php echo esc_html($brand_name); ?></a></h2>
<?php if ($brand_image) : ?>
<img src="<?php echo esc_url($brand_image); ?>" alt="<?php echo esc_html($brand_name); ?>" />
<?php endif; ?>
</div>
<?php
}
} else {
echo 'No brands found.';
}
?>
مشاهده پاسخ های این مطلب
———————————————
این مطلب از سایت انجمن وردپرس گردآوری شده است و کلیه حقوق مطلق به انجمن وردپرس می باشد در صورت مغایرت و یا بروز مشکل اطلاع دهید تا حذف گردد
منبع: انجمن وردپرس