I am having trouble getting this piece of code working. If the syntax is incorrect I apologize. I am working with a client that had a theme already in place to use and I am trying to modify it accordingly. The client is a rental property manager and needs a single search freeform text field to loop through the address, city, state, and zip code to find a match or like match for the search input field. What I have so far does not work and just returns all properties no matter the search criteria. I am not particularly sure what I am doing wrong here and would appreciate any insight into this.
if ( get_query_var('paged') ) {
$paged = get_query_var('paged');
} else if ( get_query_var('page') ) {
$paged = get_query_var('page');
} else {
$paged = 1;
}
$args = array(
'post_type' => 'property',
'paged' => $paged
);
if(isset($_GET['search_keyword'])) {
if($_GET['search_keyword']) {
$args['meta_query'][] = array(
'relation'=>'or',
array (
'key' => 'pyre_address',
'value' => $_GET['search_keyword'],
'compare' => 'LIKE',
'type' => 'CHAR'
),
array(
'key' => 'pyre_state',
'value' => $_GET['search_keyword'],
'compare' => 'LIKE',
'type' => 'CHAR'
),
array(
'key' => 'pyre_city',
'value' => $_GET['search_keyword'],
'compare' => 'LIKE',
'type' => 'CHAR'
),
array(
'key' => 'pyre_zip',
'value' => $_GET['search_keyword'],
'compare' => 'LIKE',
'type' => 'CHAR'
)
);
}
}
query_posts($args);
if(have_posts()):
get_postsorWP_Querycalls? - Dima Knivets