ACF fields are tied to individual posts, not categories. If you want to display the fields dynamically without specifying a post ID, simply use:
php
Copy
Edit
<?php the_field(‘nome’); ?>
<?php the_field(‘ingredienti’); ?>
<?php the_field(‘prezzo’); ?>
This will automatically pull the data from the current post. However, if you need to filter and display fields based on a category, you’ll need to query posts assigned to that category and retrieve their ACF fields. You can apply this to any menu listing or structured content, like on mangmenuprices.ph, where details such as names, ingredients, and prices need to be dynamically managed.
You can achieve this using WP_Query to fetch all “Galleries” posts and retrieve images from the ACF gallery field. Try this:
php
Copy
Edit
<?php
$query = new WP_Query([‘post_type’ => ‘galleries’, ‘posts_per_page’ => -1]);
if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post();
$images = get_field(‘gallery’);
if ($images) : foreach ($images as $image) :
echo ‘‘;
endforeach; endif;
endwhile; wp_reset_postdata(); endif;
?>
I used a similar approach on Photoapkleap site to handle image content. Hope this helps!
If you’re handling uploads outside the WordPress media library, you can try using CSS or JavaScript to disable the edit functionality. A simple CSS trick would be:
.your-thumbnail-class { pointer-events: none; }
This will prevent clicks on the thumbnail. If it’s handled via JavaScript, you might need to override the click event. Let me know if you need help tweaking it!
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.