Thank you for sharing the admin access.
During troubleshooting, I noticed that the "birth" and the "death" custom field values seem to be imported in the "m-d-Y" format.
( e.g. 12-19-2020 )
But the date type custom fields added through the Toolset Types plugin store the date/time values in the UNIX timestamp format.
( ref: hidden link )
If you'd like these dates to be properly processed by the View's date filters, the first step would be to convert them into UNIX timestamp. These are the steps that I'll recommend, after making a full back-up copy of the website.
1. Please go to WP Admin -> Toolset -> Custom Fields and add a new custom field group for the "Obituary" post type.
( ref: https://toolset.com/lesson-placement/lesson-placements-1620889-1620037/ )
In this new field group, you can add two "Date" type custom fields "Birth date" (slug: birth-date ) and "Death date" (slug: death-date ).
( example screenshot attached )
2. The next step is to fill these Toolset Types date fields with the values from the existing "birth" and the "death" custom fields, in each "Obituary" post.
In your active theme's "functions.php" file, you can add the following custom code:
function convert_to_timestamp_func($number)
{
$d = DateTime::createFromFormat('m-d-Y H:i:s', $number.' 00:00:00');
if ($d === false) {
return "";
} else {
return $d->getTimestamp();
}
}
add_shortcode( 'convert_dates_to_timestamp', 'convert_dates_to_timestamp_func');
function convert_dates_to_timestamp_func()
{
$post_type = 'obituary';
$old_birth_field = 'birth';
$new_birth_field = 'birth-date';
$old_death_field = 'death';
$new_death_field = 'death-date';
$args = array(
'posts_per_page' => -1,
'post_type' => $post_type,
'post_status' => 'publish'
);
$posts_array = get_posts( $args );
foreach ( $posts_array as $post ) {
$old_birth_value = get_post_meta( $post -> ID, $old_birth_field, true );
if(!empty($old_birth_value)) {
$new_birth_value = convert_to_timestamp_func($old_birth_value);
if(!empty($new_birth_value)) {
update_post_meta( $post -> ID, 'wpcf-'.$new_birth_field, $new_birth_value );
}
}
$old_death_value = get_post_meta( $post -> ID, $old_death_field, true );
if(!empty($old_death_value)) {
$new_death_value = convert_to_timestamp_func($old_death_value);
if(!empty($new_death_value)) {
update_post_meta( $post -> ID, 'wpcf-'.$new_death_field, $new_death_value );
}
}
}
}
This code will cycle through all the published "Obituary" posts, get the values of the existing "birth" and the "death" custom fields, convert them into UNIX timestamp and then save those values in the new date type custom fields, respectively.
3. To execute the code, you can create a new temporary page and add the following shortcode in it:
[convert_dates_to_timestamp]
Visit this page's front-end and the code will execute in the background. After that you can check few "Obituary" posts to confirm if the custom field values have been populated in the new date type fields.
Once confirmed, you can remove the page from step 3 and the custom code added in step 2.
After this transformation of custom fields values, you'll be able to use the date filters in the view's filters.
Note: For future "Obituary" posts, please use the Type's date type fields for storing the birth and the death dates.
In your content, you can show the output of these date fields in any date format, including the "m-d-Y" format:
( ref: https://toolset.com/documentation/customizing-sites-using-php/functions/#date )
[types field='birth-date' style='text' format='m-d-Y'][/types]
[types field='death-date' style='text' format='m-d-Y'][/types]