Default natural order issue
Hi Dave.
I was unable to remove sort options, because of instead of defaulting to most recent first (normally sort by Date DESC), it shows the oldest products first.
Ideally, I would prefer to have it as ID DESC.
Any ideas on what could be done?
If you need a particular sort order, then do not use the ‘remove sort options’ in Scalability Pro as this will use the ‘default sort order’ – the default sort order is whatever order they appear in the index or the table, depending on whether a table scan or index seek occurred. Removing the sort options is normally useful for very large product sites with millions of products.
To change your sort order to by ID DESC, you’ll need to add some custom code – something like this to your functions.php file:
function WPIorderpostsbyID( $query ) { if ( $query->is_home() && $query->is_main_query() ) {
$query->set( 'orderby', 'ID' );
$query->set( 'order', 'DESC' );
}
}
add_action( 'pre_get_posts', 'WPIorderpostsbyID' );