How to use Meta query to limit the results by date

Support reply may delay for 3 weeks due to corona virus outbreak, please send us email to support@pickplugins.com
Ticket for: Post Grid
0
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
Submit Answer
Please login to submit answer.
1 Answers
Sort By:
Best Answer
0
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,

[post_grid_today_date]

View post on imgur.com

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

Sign in to Reply
Replying as Submit

Please use https://imgur.com/upload to upload your screenshot and share url here.
You can't upload any files or attachment to our server directly for security reason, you can use 3rd party website and share file url here. here is the top file sharing website you can use.

Please login to see your tickets