Hi @rodboc,
Yes, you can override template file “event-filters.php” to your theme side by following this doc https://wp-eventmanager.com/template-files-override/
Please replace the dropdown option with your value
1st Feb
2nd Feb
…
Thank you
Thread Starter
rodboc
(@rodboc)
Thanks @hiteshmakvana, any idea how to get it done? I can go to the template but after that I’m clueless
Hi @rodboc,
You just need to create folder called wp-event-manager in your child theme and override template file called “event-filters.php”.
https://wp-eventmanager.com/template-files-override/
Inside this file please find the date and time filter code
<?php foreach ( $datetimes as $key => $value ) :
if(!strcasecmp($selected_datetime, $value) || $selected_datetime==$key) : ?>
<option selected=selected value="<?php echo $key !='datetime_any' ? $key : ""; ?>" ><?php echo $value; ?></option>
<?php else : ?>
<option value="<?php echo $key !='datetime_any' ? $key : ""; ?>" ><?php echo $value; ?></option>
<?php endif;
endforeach; ?>
please replace this code with following code :
<option value=”1feb” >1st feb</option>
<option value=”2feb” >2nd feb</option>
<option value=”3rd” >3rd feb</option>
After creating custom value in dropdown please apply those value filter by following this doc
https://wp-eventmanager.com/add-custom-field-in-search-filter/
Thank you
Thread Starter
rodboc
(@rodboc)
Thanks for your answer Hitesh but actually the code you posted is not filtering properly by date. Should I change the option value for something like “20200201” yyymmdd ?
Hi @rodboc,
May be you are not adding proper value or condition in meta key if you want to filter date from database then format of database date and time will be d-m-Y h:i:s.
I would suggest you to convert your 1feb to <option value=”01-02-2020” >1st feb</option>
Thank you
Thread Starter
rodboc
(@rodboc)
Thanks Hitesh, but it is not working after the last changes. My code looks like that
<?php if ( $datetimes) : ?>
<div class="wpem-form-group">
<label for="search_datetimes" class="wpem-form-label"><?php _e( 'Any dates', 'wp-event-manager' ); ?></label>
<select name="search_datetimes[]" id="search_datetimes" class="event-manager-category-dropdown" data-placeholder="Choose any date…" data-no_results_text="No results match" data-multiple_text="<?php _e('Select Some Options','wp-event-manager'); ?>" >
<option value=”01-02-2020 00:00:00” >1st feb</option>
<option value=”01-02-2020” >1st feb</option>
</select>
</div>
<?php endif; ?>
-
This reply was modified 6 years, 4 months ago by
rodboc.
Hi @rodboc,
Once you have made changes in the template file you need to filter events by your custom value by following this doc https://wp-eventmanager.com/add-custom-field-in-search-filter/
Thank