picandocodigo / List-Category-Posts

WordPress plugin which allows you to list posts from a category into a post/page using the [catlist] shortcode.
http://wordpress.org/extend/plugins/list-category-posts/
GNU General Public License v2.0
241 stars 112 forks source link

Formatting custom field date with latest template #487

Closed redweatherday closed 2 years ago

redweatherday commented 2 years ago

Format customfield date

No formatting of date

[catlist conditional_title="WALKS" catlist template=sw-custom-template-upcoming-walks link_titles=true name=wednesday-walks,thursday-walks-daytime,thursday-walks-evening,saturday-walks,sunday-walks post_type=any post_status=publish,future numberposts=10 customfield_compare=walk_date,greaterthanequal,today,DATE customfield_display=walk_start_time,walk_grade,walk_distance customfield_display_name=no customfield_display_separately=yes customfield_orderby=walk_date order=asc no_posts_text="To be announced" posts_morelink="Find out more about this walk »"]

Version 0.87

Hi, in issue 'How to format a custom field date #365' you kindly helped with resolving an issue when formatting a 'customfield date' when using an LCP template. This worked fine and I closed issue #365.

Having recently discovered the default template has changed, and on using the updated template this line (provided in #365):

$lcp_display_output .= $dateTime->format('l, jS F Y');

creates a 'critical issue' in Wordpress.

The 'customfield date' is a future date and not related to the 'post date' or 'modified date' so I doubt I can format this with CSS.

This is the short code I use:

[catlist conditional_title="WALKS" catlist template=sw-custom-template-upcoming-walks link_titles=true name=wednesday-walks,thursday-walks-daytime,thursday-walks-evening,saturday-walks,sunday-walks post_type=any post_status=publish,future numberposts=10 customfield_compare=walk_date,greaterthanequal,today,DATE customfield_display=walk_start_time,walk_grade,walk_distance customfield_display_name=no customfield_display_separately=yes customfield_orderby=walk_date order=asc no_posts_text="To be announced" posts_morelink="Find out more about this walk »"]

As suggested in #365 and in order not to duplicate the 'customfield date', the customfield 'walk_date' is removed from customfield_display.

Removing the offending line in the latest template and re-adding 'customfield walk_date' to customfield_display resolves the issue but leaves me back at the original problem of the date displaying as 20222911.

Any suggestions on resolving this issue with the latest LCP template?

Attached files show the formatted dates using the old template and latest template and my original custom template file.

Screenshot from 2022-09-11 10-55-20 Screenshot from 2022-09-11 10-52-00 Screenshot from 2022-09-11 10-47-22

redweatherday commented 2 years ago

Format customfield date

No formatting of date

[catlist conditional_title="WALKS" catlist template=sw-custom-template-upcoming-walks link_titles=true name=wednesday-walks,thursday-walks-daytime,thursday-walks-evening,saturday-walks,sunday-walks post_type=any post_status=publish,future numberposts=10 customfield_compare=walk_date,greaterthanequal,today,DATE customfield_display=walk_start_time,walk_grade,walk_distance customfield_display_name=no customfield_display_separately=yes customfield_orderby=walk_date order=asc no_posts_text="To be announced" posts_morelink="Find out more about this walk »"]

Version 0.87

Hi, in issue 'How to format a custom field date #365' you kindly helped with resolving an issue when formatting a 'customfield date' when using an LCP template. This worked fine and I closed issue #365.

Having recently discovered the default template has changed, and on using the updated template this line (provided in #365):

$lcp_display_output .= $dateTime->format('l, jS F Y');

creates a 'critical issue' in Wordpress.

The 'customfield date' is a future date and not related to the 'post date' or 'modified date' so I doubt I can format this with CSS.

This is the short code I use:

[catlist conditional_title="WALKS" catlist template=sw-custom-template-upcoming-walks link_titles=true name=wednesday-walks,thursday-walks-daytime,thursday-walks-evening,saturday-walks,sunday-walks post_type=any post_status=publish,future numberposts=10 customfield_compare=walk_date,greaterthanequal,today,DATE customfield_display=walk_start_time,walk_grade,walk_distance customfield_display_name=no customfield_display_separately=yes customfield_orderby=walk_date order=asc no_posts_text="To be announced" posts_morelink="Find out more about this walk »"]

As suggested in #365 and in order not to duplicate the 'customfield date', the customfield 'walk_date' is removed from customfield_display.

Removing the offending line in the latest template and re-adding 'customfield walk_date' to customfield_display resolves the issue but leaves me back at the original problem of the date displaying as 20222911.

Any suggestions on resolving this issue with the latest LCP template?

Attached files show the formatted dates using the old template and latest template and my original custom template file.

Screenshot from 2022-09-11 10-55-20 Screenshot from 2022-09-11 10-52-00 Screenshot from 2022-09-11 10-47-22

I seemed to have fixed this by removing the spaces in this line: $date = get_post_meta( $post->ID, 'walk_date', true ); and replaced it with $date = get_post_meta($post->ID, 'walk_date', true);

redweatherday commented 2 years ago

Will now close this issue.