WP_Meta_Query Generator

Overview

Use this tool to create custom code for WordPress Meta Query with WP_Meta_Query class.

Usage

  • Fill in the user-friendly form.
  • Click the “Update Code” button.
  • Copy the code to your project.
  • Or save it as a snippet and share with the community.

Examples

If you are still learning how to use this tool, check out the following examples:

The variable used in the code.
The MySQL keyword used to join the clauses of the query.
Meta key to filter by.
Operator used for comparing the value.
Select from your saved Meta Query snippets.
Meta value to filter by.
Meta value type.
Meta key to filter by.
Operator used for comparing the value.
Select from your saved Meta Query snippets.
Meta value to filter by.
Meta value type.
Meta key to filter by.
Operator used for comparing the value.
Select from your saved Meta Query snippets.
Meta value to filter by.
Meta value type.
Meta key to filter by.
Operator used for comparing the value.
Select from your saved Meta Query snippets.
Meta value to filter by.
Meta value type.
Meta key to filter by.
Operator used for comparing the value.
Select from your saved Meta Query snippets.
Meta value to filter by.
Meta value type.
  Save Snippet
$meta_query = array(
	'relation' => 'OR',
	array(
		'key'     => 'color',
		'value'   => 'blue',
		'compare' => '=',
	),
	array(
		'key'     => 'color',
		'value'   => 'red',
		'compare' => '=',
	),
);