How to use Meta query to limit the results by date

Ticket for: Combo Blocks
0
How to use Meta query to limit the results by date 1
James Witika
Feb 26, 2020 11:17 AM 1 Answers
Member Since Dec 2019
Subscribed Subscribe Not subscribe
Flag(0)

I am using Post Grid to display post types "Event" which has a meta key "event-start-date". I can force it to hide past events by passing in:
Key: event-start-date
Value: 1582691760 (unix timestamp for 26/FEB/2020)
Compare: >
Type: event (post type)

However, I need the "value" to be dynamically determined and was hoping to use something like "$today" or something of that equivalent.

Can you please advise the best way I can use your Post Grid plugin to filter my custom post type by the meta field "event-start-date"?

2 Subscribers
How to use Meta query to limit the results by date 1
How to use Meta query to limit the results by date 3
Submit Answer
Please login to submit answer.
1 Answers
Sort By:
Best Answer
0
How to use Meta query to limit the results by date 4
PickPlugins
Feb 28, 2020
Flag(0)

Welcome to our forum.

Yes, we have a solution for this, meta value field has shortcode support to pass dynamic values like you want, please use following shortcode into meta value field,

2024-03-28

https://imgur.com/deOROro

it will return date following format  Y-m-d  in case you need to different date output you can use different shortcode define by you, simple rename following function to generate your shortcode

add_shortcode('post_grid_today_date','post_grid_today_date_20200228');

function post_grid_today_date_20200228(){
  
  return date('Y-m-d');
  
}

 

Hope that help you.

Regards

How to use Meta query to limit the results by date 5
Jörg Hoewner
- Jul 11, 2022 01:39 PM
Flag (0)
0

Hello, I have same problem and shortcode solution is not working for me. Shortcode itself return current date but not working in post grid Advance Query!

Regards

Sign in to Reply
Replying as Submit