This is a bit hacky, but you could create your own template and then reformat the date.
start by creating a folder list-category-posts
in your theme directory. copy the default.php
template there from the plugin’s templates folder, and rename it custom.php
, or whatever you’d like.
within that custom.php file, find the line:
//Show the title and link to the post:
$lcp_display_output .= $this->get_post_title($single);
and replace it with:
//Show the title and link to the post:
$temp_title = $this->get_post_title($single);
preg_match("/\<a.*href=\"(.*?)\".*?\>(.*)\<\/a\>+/", $temp_title, $matches);
$temp_date = substr($matches[2], 0, 10);
$new_title = substr($matches[2], 11);
$timestamp = strtotime($temp_date);
$new_date = date("j F, Y", $timestamp);
$lcp_display_output .= '<a href="' . $matches[1] . '">' . $new_title . ' - ' . $new_date . '</a>';
For this to work, your posts should be titled:
YYYY/MM/DD Event title
If the day or month is a single digit, it MUST have a leading zero.
The reformatted result will be:
Event title – 9 September, 2011
The part that’s reformatting the date is here:
$new_date = date("j F, Y", $timestamp);
If you want to change this, have a look at PHP’s Date function for your options.
The last line is reassembling the various bits back together, you can change the order of title – date as well as the hyphen separating them if you’d like.
The shortcode to load your custom.php template and sort by title is:
[catlist name=calendar template=custom orderby=title]