Haven’t implemented it yet.
It’s complicated since you’re using strings to define custom fields. So let’s say a given date for this custom field is “29/11/2013, 22:00”. If I use the PHP strtotime
function on this string, it returns false because it’s not recognized as a correct date format.
I think an alternative way of achieving this could be using a plugin for getting a date type on a custom field and ordering by that custom field. These links may help:
http://wordpress.org/support/topic/plugin-advanced-custom-fields-date-time-picker?replies=8
Custom Field Template
Thread Starter
Dani
(@danicasati)
It seems very hard to implement…
Any suggestion?
HI,
maybe you’ve already solved this but I went crazy over this today wondering why it did not work (no conflict, no weird code…), so I landed on this page.
Since I’ve found a workaround that really works and it is super simple, I thought I could share it with you.
I am using the date picker from Advanced Custom Fields to add a date to posts related to events which then I order with your plugin on a page.
The date picker basically returns a numerical string like 20140520 so, unless you have other custom fields you need to order by, all you need to do is to edit list-category-posts/include/CatList.php:
In the Added custom taxonomy section find these lines
if ( $this->lcp_not_empty('customfield_orderby') ):
$args['orderby'] = 'meta_value';
$args['meta_key'] = $this->params['customfield_orderby'];
endif;
and change the 2nd one to:
$args['orderby'] = 'meta_value_num';
That’s all there is to it! 😉 It works like a charm.
Happy WordPressing!