Hi,
i have two issues in a filter for a other view.
it only works the category-filter on this: versteckter Link
but not the date-filter below. -> its a date field
its all in there and data is good. You can see it -> Timestamps are there
And second question: How can i format the timestamps to readable dates?
thx in advance - i dont find some in Forum.
alex
Hi Alex,
Thank you for contacting us and I'd be happy to assist.
To troubleshoot and suggest the next steps, I'll need to see how this view and the date type field are set up in the back end.
Can you please share temporary admin login details, in reply to this message?
Note: Your next reply will be private and making a complete backup copy is recommended before sharing the access details.
regards,
Waqar
Thank you for sharing the access details.
I've removed the query filter and search field code for the "letzter Termin" field and added it again, with slightly different settings and it seems to be working now.
( screenshot: versteckter Link )
Here is the updated code for the search field, in the "Search and Pagination" section:
<div class="form-group">
<label for="wpv-wpcf-letzter-termin_min">[wpml-string context="wpv-views"]letzter Termin von[/wpml-string]</label>
[wpv-control-postmeta type="date" field="wpcf-letzter-termin" date_format="F j Y" default_date="NOW()" url_param="wpv-wpcf-letzter-termin_min"]
</div>
<div class="form-group">
<label for="wpv-wpcf-letzter-termin_max">[wpml-string context="wpv-views"]letzter Termin bis[/wpml-string]</label>
[wpv-control-postmeta type="date" field="wpcf-letzter-termin" date_format="F j Y" default_date="NOW()" url_param="wpv-wpcf-letzter-termin_max"]
</div>
hi thank you,
i want to show the date fields as type="select" - how can i do that with date-format? - Its only show timestamps.
And: how can i set versteckter Link to show only post with "letzter Termin" only in past? i do it with screenshot
thank you
best regards - alex
Thanks for writing back.
I'm afraid, for the date type custom fields, the select type search field filter is not supported. This is why you're seeing the raw, timestamp values when you change the field type to "select".
For the past date query filter, you only needed to change the type of the filtration to the 'number' in the view "Veranstaltungs-liste-date-archiv".
( screenshot: versteckter Link )
Hi Waqar,
1. is there a jquery to reformat the timestamps to readable dates?
2. for the past date query filter - are you sure? - i did this on screenshot but it dont work - look at mine Screenshot. I also tried it with "string".
thx for an answer - best regards - alex
1. I was able to convert the timestamp values in the search fields, using some custom script, with the help of code from this guide:
versteckter Link
You can see the code included and working in the view "Veranstaltungs-Liste-Filter01-archiv".
jQuery( document ).on( 'ready', function( event, data ) {
jQuery('select[name="wpv-wpcf-letzter-termin_min"] option, select[name="wpv-wpcf-letzter-termin_max"] option').each(function () {
var $this = jQuery(this);
if ($this.length) {
var selText = $this.text();
console.log(selText);
var conVerted = unixToDatetime(selText);
$this.text(conVerted);
}
});
});
function unixToDatetime(timestamp){
// Unixtimestamp
var unixtimestamp = timestamp;
// Months array
var months_arr = ['January','February','March','April','May','June','July','August','September','October','November','December'];
// Convert timestamp to milliseconds
var date = new Date(unixtimestamp*1000);
// Year
var year = date.getFullYear();
// Month
var month = months_arr[date.getMonth()];
// Day
var day = date.getDate();
// Hours
var hours = date.getHours();
// Minutes
var minutes = "0" + date.getMinutes();
// Seconds
var seconds = "0" + date.getSeconds();
// Display date time in F j Y format
var convdataTime = month+' '+day+' '+year;
return convdataTime;
}
Note: The custom code examples from our forum are shared to get you started in the right direction. You're welcome to adjust them as needed and for more personalized customization assistance, you can consider hiring a professional from our list of recommended contractors:
https://toolset.com/contractors/
2. I couldn't find the page or the view that you referred to in your last message. Can you please share the link to the page where this view can be seen and the query filter is not working as expected?
hi,
thx a lot for question 1 ! -
for question 2: this is in view 10935
thx for help, best regards - alex
ps: and sorry for delay, i was ill
Glad I could help.
The view "Veranstaltungs-liste-date-archiv" is set to show the "Termine" repeating field group posts, which are technically separate post types from the parent "Veranstaltungen" post type.
The custom field "letzter Termin" is not part of the repeating field group "Termine", which means that they are stored with the parent "Veranstaltungen" posts and not the "Termine" repeating field group posts.
This is why the query filter for this field is not working in this view. Only the custom fields which are directly part of the repeating field group "Termine" can be used for filtering this view.
Hi,
oh sorry - but it was in view 12454 - >
i tried it in loop object with condition:
[wpv-conditional if="( '[types field='ort' item='@termine-veranst.parent'][/types]' lte '[NOW]' )"]
or
[wpv-conditional if="( '[types field='datum-und-uhrzeit' style='text' format='d'][/types]' lte '[NOW]' )"]
but this dont work.
thx for helping - best regards - alex
I've created a separate ticket for your question about the conditional display statement and will follow up on it shortly.
( ref: https://toolset.com/forums/topic/split-conditional-display-for-the-date-field-not-working-as-expected/ )
You're welcome to mark this ticket as resolved and start a new one for each new question or concern.