WP-Query doesn´t work with variable
-
Hi,
today i have a strange problem. It´s my first try with WordPress & Ajax, but the most works… except a little part.
The Mainfunction is that after a few inputs in a form under the form some entries should be visible. With the Inputs i build a query like that$table_plztour = $wpdb->prefix . "za_plztour"; $zeit = $_POST['zeit']; $ortid = $_POST['ortid']; $lkw = wp_strip_all_tags($_POST['tournr']); $datum = $_POST['datum']; $plz = $wpdb->get_var ( "SELECT plz FROM $table_plztour WHERE id=$ortid" ); $ort = $wpdb->get_var ( "SELECT ort FROM $table_plztour WHERE id=$ortid" ); echo 'Die Zeit: '.$datum.' um '.$zeit.'<br>'; echo 'Der Ort: '.$plz.' '.$ort . ' für Tour '.$lkw.'<br>'; $meta_query = array(); if (!empty($datum)) { $meta_query[] = array( 'key' => '_lieferdatum', 'value' => $datum, 'compare' => '=' ); } if (!empty($lkw)) { $meta_query[] = array( 'key' => '_tour', 'value' => $lkw, 'compare' => 'LIKE' ); } $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1; $argus=array( 'post_type' => 'liefertermin', 'posts_per_page' => 10, 'paged' => $paged, 'meta_query' => $meta_query ); $wp_query = new WP_Query($argus);The Problem is this Part
if (!empty($lkw)) { $meta_query[] = array( 'key' => '_tour', 'value' => $lkw, 'compare' => 'LIKE' ); }If i change $lkw to e.g. ‘502’ everything works fine. If i used $lkw
the Query return no results! I do not know where the error is 🙁Ati74
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
The topic ‘WP-Query doesn´t work with variable’ is closed to new replies.