Skip to content

Meta query date functions#158

Open
roborourke wants to merge 5 commits intoryanwelcher:trunkfrom
roborourke:meta-query-date-functions
Open

Meta query date functions#158
roborourke wants to merge 5 commits intoryanwelcher:trunkfrom
roborourke:meta-query-date-functions

Conversation

@roborourke
Copy link
Copy Markdown

In some cases with a meta query you might want to build out a date query and use dynamic ranges, or make comparisons to date information for other purposes without necessarily casting values to date/time types. This is a little step in that direction that we've used in projects via a pre_get_posts filter, would be great to get your thoughts on the approach.

Added support for dynamic date functions in meta queries.
Added information about using MySQL date functions in meta queries.
Added support for dynamic date functions using MySQL.
@ryanwelcher
Copy link
Copy Markdown
Owner

ryanwelcher commented Apr 16, 2026

Overall, I love this idea!

I have a couple of thoughts that I'd love to get your input on:

  1. The strings being passed are very developer focused will not mean anything to many (or even most) users of the plugin. Perhaps instead we can use more human readable strings?
  2. The user will also have to know how the meta date is formatted in order to build the value out. There may be some need to expose this to them somehow. I imaged that ACF/SCF, Pods etc may handle that data differently - I have not checked to confirm this however.
  3. It would be great to extend this same approach to the Post Date controls so perhaps this might be better done in the Query_Params_Generator class after the rest of the parameters are processed?

Great work and thanks for the PR!

@roborourke
Copy link
Copy Markdown
Author

Yeah I wondered about the params generator but felt that had the UI and options already there for dynamic dates. I’ll look again to see what consolidation we can do. I’d gone for developer focused terms I think because the advanced meta queries felt like you need to know about data types and things already, but you’re right, they can be any strings so user friendly terms is a great shout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants