Hi I have a drop down list with the first option shown is an option i have set as DATE.. I need an if statement that runs if the date is empty or if the first options which says "DATE" is selected..Right know MY AJAX only works if the date selected..
This is my drop down
<?php
$dates = array();
$argez = (array( 'post_type' => 'latest_message'));
query_posts( $argez );
if (have_posts()) : while (have_posts()) : the_post();
$dates[] = get_the_date();
$dates = array_unique($dates);
print_r($datesun);
endwhile;
echo '<option value="#">DATE</option>';
foreach($dates as $date) {
echo '<option value="' . $date . '">' . $date .'</option> ';
}
endif;
?>
This is my ajax
global $post, $wpdb;
if ($_POST["series"]!=0 ) {
$series = array($_POST['series']);
} else {
$series = get_terms( 'series', array('fields' => 'ids') );
//$series = array(implode(', ',$series));
}
if ($_POST["speaker"]!=0 ) {
$speaker = array($_POST["speaker"]);
} else {
$speaker = get_terms( 'speaker', array('fields' => 'ids') );
//$speaker = array(implode(', ',$speaker));
}
if ($_POST["topic"]!=0 ) {
$topic = array($_POST["topic"]);
} else {
$topic = get_terms( 'topic', array('fields' => 'ids') );
//$topic = array(implode(', ',$topic));
}
if ($_POST["date"]!= NULL || $_POST["date"] == 'DATE') {
$dates = strtotime($_POST["date"]);
}
else {
}
wp_reset_query();
$myquery= array(
'post_type' => 'latest_message',
'tax_query' => array(
array(
'taxonomy' => 'series',
'terms' => $series,
'field' => 'id'
),
array(
'taxonomy' => 'speaker',
'terms' => $speaker,
'field' => 'id',
),
array(
'taxonomy' => 'topic',
'terms' => $topic,
'field' => 'id',
)
),
'date_query' => array(
'year' => date('Y', $dates),
'month' => date('m', $dates),
'day' => date('d', $dates),
),
);
print_r($myquery);
query_posts($myquery);
Part of the problem is the date array brings in this information below.. How do i get it to still run because there isn't any information matching that date.. Any ideas
[date_query] => Array ( [year] => 1970 [month] => 01 [day] => 01