I think some other function hooks in the filter ‘rpwwt_widget_posts_args’ or is mixing up the sort direction in other ways. hat is possible because the plugin does not set the sort direction explicitely.
So you’re saying that by default it should be displaying the most recent first?
I don’t see anything hooking into the filter, how else can I make sure it actually displays most recent posts first?
I do not know what the reason for your experience is but there is a way to fix it: please insert at the end of the functions.php these lines:
/**
* Tells the plugin 'Recent Posts Widget with Thumbnails' explicitely
* to sort the posts from new to old
*
*/
function rpwwt_force_desc_sortorder ( $query_args ) {
$query_args[ 'order' ] = 'DESC';
return $query_args;
}
add_filter( 'rpwwt_widget_posts_args', 'rpwwt_force_desc_sortorder' );
That way the plugin gets the explicit call to sort new-to-old.
Hi. Thank you very much in advance for your time.
I have a similar issue: posts are not being ordered by date, but that’s only happening in single posts view. I’ve added your function (including also $query_args[‘order’] = ‘date’;) but still the same:
http://escolessantcugat.com/es/noticias/ (archive view – works fine)
http://escolessantcugat.com/es/existe-el-enamoramiento-entre-los-ninos-pequenos/ (single view – not working)
It’s weird because the widget should display the same posts in both archive and single pages right?
Thanks,
Pilar
Hola, Pilar, my silly question: is the “random order” checkbox activated?
Hi Martin, thanks for answering.
I have solved the issue: The random order was due to a previous function included in my theme that makes some post-types to show always in random order. The function excluded the blog page, but not the single pages for regular posts. I have just added !is_single()
to the if
statement of the function and now your plugins works fine in all views.
Thanks again,
Pilar