Using F j, Y date format in loopers

Hi, I’ve followed the thread at Layouts/Loopers: How to display posts based on an ACF date picker?. I’m doing something very similar, where I want to only show posts where the end_date is today or later.

My query string is:
post_type=programs&post_status=publish&meta_query[0][key]=type&meta_query[0][value]= class&meta_key[1]=end_date(“F j, Y”)&meta_compare[1]=>=&meta_value[1]={{dc:global:date format=“F j, Y”}}&orderby=meta_value&meta_key=start_date&order=asc&posts_per_page=-1

But it’s not returning anything. I’m guessing it’s because of the F j, Y date format, but can you confirm? If that’s the case, is there a way to make that work?

Thanks,
Danni

Hi Danni,

Thanks for reaching out.
You need to use the format in the Meta Value only not in the meta key. You need to mention the exact format that has been used to store the data in the specified meta key.
You can check my colleague Runel’s comment in the following thread and maintain the same in your Query String.

Hope it helps.
Thanks

Thanks. I changed the query to:

post_type=programs&post_status=publish&meta_query[0][key]=type&meta_query[0][value]=class&meta_key[1]=end_date&meta_compare[1]=>=&meta_value[1]={{dc:global:date format=’F j, Y’}}&orderby=meta_value&meta_key=start_date&order=asc&posts_per_page=-1

But it still doesn’t work. I’m using F j, Y format in the ACF field (both Display Format and Return Format) and for the default setting on the site. The other examples I’m seeing on the forums, etc. use Ymd, so I’m wondering if the problem is with the F j, Y format… is it stored as a string and hence the looper can’t do the date comparison? OR, am I just formatting the query string incorrectly?

Hi Danni,

It seems that you are not making the Meta Query argument array properly. Can you please make it and then use the http_build_query function to format it into Query String, as described in the reference threads.



If that does not work, I would suggest you share the argument array and your website login credentials for your site in a secure note to examine it further, including:

– WordPress Site URL & Login URL
– WordPress Admin username/password
– Specific page where you have added this Query String.

To create a secure note, click the key icon underneath any of your posts.

Thanks

I’ve read those threads before but I’m not a PHP developer … and I get to the part where it says “Then, output that somehow utilizing http_build_query(), which will format our string accordingly” and I’m stumped. I guess the “output that somehow” needs a bit more information for me.

Hey Danni,

As my colleague says, we need to check on your setup properly. Please give us the following information in a Secure Note.

  • WordPress Login URL
  • Admin level username and password
  • Specific page where you have added this Query String.

You can find the Secure Note button at the bottom of your posts.

Thank you.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.