Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compare value type setting in meta_query #99

Open
jasalt opened this issue Jan 5, 2025 · 0 comments
Open

Add compare value type setting in meta_query #99

jasalt opened this issue Jan 5, 2025 · 0 comments

Comments

@jasalt
Copy link

jasalt commented Jan 5, 2025

Adding value type comparison would allow filtering by post meta compared as type. Example WP_Query args using dates in post meta which I would like to achieve:

[
'post_type' => ['post', 'event'],
'meta_query' => [
	'relation' => 'AND',
	[
	'key' => 'show_in_bulletin_section,
	'value' => 'yes'
	],
  [
	'key' => 'show_in_bulletin_section_until',
	'value' => date('Y-m-d', strtotime('-1 day')), // includes today in results
	//'value' => date('Y-m-d'), // today would not be included
	'compare' => '>',
	'type' => 'DATETIME'  // <- This is not possible with the plugin AFAIK
  ]
],
]

Wondering how well this could be achieved while avoiding to allow user inject PHP via value fields. Maybe some preset values could be used as in #54.

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

No branches or pull requests

1 participant