Closed braekling closed 12 months ago
This is complicated because users might have a plethora of different filters they would like to apply to custom fields, not just for dates. This is why we encouraged to implement such filtering in custom templates. Otherwise we would end up with many new parameters to satisfy all possible scenarios: dates, numbers, strings, etc.
Perhaps we could add a few built in parsing methods for dates,
Thanks for your quick response!
I understand the problem that arises with specific custom field types - the complexity would become unmanageable, because the additional parameters (such as *_display_name
) always have to be included, too.
So, as you suggested, I had a look how templates work, and I created my own one form the default template. There I added my "custom date field" by adding this code between custom fields and post thumbnail:
//Event date:
$event_date = get_post_meta($post->ID, '_event_date', true);
if (!empty($event_date)) {
$event_date_obj = strtotime($event_date);
$lcp_display_output .= $this->wrapper->wrap(date($this->params['dateformat'], $event_date_obj), 'div', 'lcp-customfield-date');
}
It also uses the dateformat
parameter of the catlist
shortcode, so that format changes don't require changes in the PHP file. Maybe this will help others with similar requirements.
First of all thanks for your useful plugin! Because we are using it to display a specific event post type which contains an event date within a custom field, something like a
customfield_date_display
andcustomfield_date_dateformat
would be very helpful.Suggested feature
We want to add the event date to the event post list. A
customfield_date_display
and corresponding parameters would allow us to show such a field (same as the existingcustomfield_display
,customfield_display_name
, etc.), but the additionalcustomfield_date_dateformat
will also allow us to format the date to be shown asd.m.Y H:i
instead ofY-m-d H:i:s
as it is stored in the database.Current usage
Currently, we can only show the custom field as is, which means all dates are shown as
Y-m-d H:i:s
, which may cause some confusion in Germany. :wink:Shortcode examples
This is how it currently looks like:
[catlist post_type="event" customfield_orderby="_event_date" order="asc" customfield_display="_event_date" customfield_display_name="no"]
This is how we would like to use it:
[catlist post_type="event" customfield_orderby="_event_date" order="asc" customfield_date_display="_event_date" customfield_date_display_name="no" customfield_date_dateformat="d.m.Y H:i"]
(Of course, the parameter naming is just an example.)