Hello again.
Because this is an important feature for us I had to find some patch for this and found it with use of this solution:
https://jeffri.me/2012/01/sort-by-latest-post-for-wp_list_categories/
so i add in function.php
$pieces = array( 'fields', 'join', 'where', 'orderby', 'order', 'limits' );
$clauses = apply_filters( 'terms_clauses', compact( $pieces ), $taxonomies, $args );
function filter_term_sort_by_latest_post_clauses( $pieces, $taxonomies, $args )
{
global $wpdb;
if ( in_array('category', $taxonomies) && $args['orderby'] == 'latest_post' )
{
$pieces['fields'] .= ", MAX(p.post_date) AS last_date";
$pieces['join'] .= " JOIN $wpdb->term_relationships AS tr JOIN $wpdb->posts AS p ON p.ID=tr.object_id AND tr.term_taxonomy_id=tt.term_taxonomy_id";
$pieces['where'] .= " GROUP BY t.term_id";
$pieces['orderby'] = "ORDER BY last_date";
$pieces['order'] = "DESC"; // DESC or ASC
}
return $pieces;
}
add_filter('terms_clauses', 'filter_term_sort_by_latest_post_clauses', 10, 3);
and changed in your plugin line
$subs = wp_list_categories(array($parent => $category_id, ‘hide_empty’ => $hide_empty_cats, ‘show_count’ => $show_post_count, ‘exclude’ => $excluded, ‘title_li’ => null, ‘show_option_none’ => ”, ‘echo’ => 0, ‘order’ => $order));
to
$subs = wp_list_categories(array($parent => $category_id, ‘hide_empty’ => $hide_empty_cats, ‘show_count’ => $show_post_count, ‘exclude’ => $excluded, ‘title_li’ => null, ‘show_option_none’ => ”, ‘echo’ => 0, ‘orderby’ => ‘latest_post’));
Can you add this option in your next version of plugin?
It will be useful for more users but me and we could continue to use your updates if we do not have to change this line.
Best regards,
Danilo Cubrovic