Skip to content

Instantly share code, notes, and snippets.

@elias1435
Created July 29, 2022 09:53
Show Gist options
  • Save elias1435/b96dcedcf57f89009e58fe8730d54bf2 to your computer and use it in GitHub Desktop.
Save elias1435/b96dcedcf57f89009e58fe8730d54bf2 to your computer and use it in GitHub Desktop.
Elementor - SORT POSTS BASED ON A CUSTOM DATE FIELD
/* Sort Posts by Custom Date Field */
add_action( 'elementor/query/event_sort_date', function( $query ) {
$query->set( 'meta_key', 'event_date' );
$query->set( 'orderby', 'meta_value_num' );
$query->set( 'order', 'ASC' );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment