Skip to content

Instantly share code, notes, and snippets.

@edingc
Created January 30, 2014 23:06
Show Gist options
  • Save edingc/8722049 to your computer and use it in GitHub Desktop.
Save edingc/8722049 to your computer and use it in GitHub Desktop.
<?php
if ( ( $_GET["var1"] != '' ) || ( $_GET["var2"] != '' ) || ( $_GET["var3"] != '' ) ) {
if ( $_GET["var1"] != '' ) {
$meta_query[] = array( 'key' => 'meta_value1', 'value' => $_GET["var1"], 'compare' => '=' );
}
if ( $_GET["var2"] != '' ) {
$meta_query[] = array( 'key' => 'meta_value2', 'value' => $_GET["var2"], 'compare' => '=' );
}
if ( $_GET["var3"] != '' ) {
$meta_query[] = array( 'key' => 'meta_value3', 'value' => $_GET["var3"], 'compare' => '=' );
}
$args = array (
'post_type' => 'cpt_type',
'meta_query' => $meta_query
);
} else {
$args = array (
'post_type' => 'cpt_type'
);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment