function custom_homepage_product_query( $query ) {
if ( ! is_admin() && $query->is_main_query() && is_front_page() ) {
$query->set( 'orderby', 'date' );
$query->set( 'order', 'DESC' );
}
}
add_action( 'pre_get_posts', 'custom_homepage_product_query' );
I tried adding the following code to the end of functions.php, but it doesn't work.