B
B
Bearax2021-11-01 11:28:58
WordPress
Bearax, 2021-11-01 11:28:58

Why isn't ACF displaying an image?

Good day. The site has ACF and WPML plugins. Problem in what means:
1) There is an arbitrary type of records with articles and categories.
2) With the help of ACF, I displayed images for categories.
3) At first everything is fine and the images are displayed.
4) After I add articles to these categories, category images are no longer displayed.

What data to provide to fully understand the situation? I've looked all over the forums and couldn't find anything. Please help with this question, where can I find this problem? Has anyone encountered this problem before?

<img src="<?php if( get_field('image_cat') ): ?><?php the_field('image_cat'); ?><?php endif; ?>" class="first-screen-thumbnail"/>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
B
Bearax, 2021-11-01
@Bearax

In the end, I solved the problem myself. I share the solution, maybe someone will need it:

<?php $catid = get_queried_object()->term_id;?>

<img src="<?php the_field('image_cat', 'service_taxonomy_' . $catid); ?>" class="first-screen-thumbnail"/>

G
godsplane, 2021-11-01
@godsplane

Nothing is clear without the code, but most likely you display the fields like this
<?php the_field('image');?>
Try this
<?php the_field('image' , $cat);?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question