Thank you, indeed it should be $p like in the rest of the code!
It works fine now for regular prices. However when I have sale price and regular price for one product it displays: 0.00 and I get error : “Trying to get property of non-object…” on this line:
$product = new WC_Product($p->ID);
Is there anything else I missed?
I solved it by setting image field to Object.
Thanks for reply, I dropped it but now I have to resolve the issue.
Basically I have a date picker custom field where user picks the event date when creating new post. I display all posts on a page and I order them by this event date. What I need is a filter option above the posts where you can pick the month to see only the events happening that month.
Thank you for reply!
But does it mean that if I have events over last two years, I would need to duplicate this code 24 times, to create start and end array for every single month… ? And also every month add new one to the list?
Is there a way to make this automatic? So that every month new month shows up on that filter?
I followed instructions from Jonathan above but the code posted by Jonathan doesn’t work.
I set the image to Object in repeater field, this is my code:
$image_1 = get_sub_field('location_image');
<?php if($image_1): ?>
<img src="<?php echo $image_1['sizes']['medium']; ?>" style="max-width:300px;" alt="" />
<?php endif; ?>
when I remove
['sizes']['medium']
it works fine.
What’s the problem? Should there somewhere be [‘url’] added?
I have the same iisue, have you found solution?
I ahve the same issue, have you found solution to this?
Thanks Blacksunice for posting your solution, this solved my issue too!
Edit: Actually I just realised that I had a pin, but becuase map is not centered, I couldn’t see it. what a mess.
I ahve the same issue, my map is working in the backend – when I type address I can see the marker, but in front end no marker. I haven’t changed anything in the code from documentation, apart my field name in
$location = get_field('map');
What else am I missing?
You solution doesn’t mean much to me, have you changed anything in the JS file?
I think this should help (bottom of the page):
http://www.advancedcustomfields.com/resources/field-types/date-picker/
Use the code that Mathias suggested, and place your code after:
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
$the_query->the_post();
you can break the php to place your html like this:
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
$the_query->the_post(); ?>
<!-- your code here -->
<?php } } else { ?>
<h2>Not Found</h2>
<?php //endif; ?>
<?php } ?>
<?php wp_reset_postdata(); ?>
Thank you! The problem must have been with the way I wrote the loop, now it works fine and the category is displayed properly too now.
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!
🤔 Curious about the ACF user experience? So are we! Help guide the evolution of ACF by taking part in our first ever Annual Survey and guarantee you’re represented in the results. https://t.co/0cgr9ZFOJ5
— Advanced Custom Fields (@wp_acf) May 8, 2023
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.