Change default sorting to a custom attribute


Is it possible to change the default sorting from post_date to another date created as an attribute? I list music events nearby and want to have ascending order date (rather than post date).


Unfortunately there’s no such feature at the moment, but we have it on the roadmap.

Is there any other option to work around it while you work on that feature?

It’s possible, but this would require code customizations, if you’re familiar with customizations please try using the pre_get_posts WordPress action.

Hi Ihor, I am not familiar unfortunately. Is some sort of snippet required? Any help will be greatly appreciated as in my case it displays events/listings that will take place further in the future ahead of more closer one.

Please check this topic to start Change order of listings to random

But please note that it can require further customization and if you are not familiar with the code customization then please consider hiring someone for custom work

Hi Yevhen, I am aware of the random change option. Actually would be great to have a snippet that allows to sort by the chosen attribute - in this case by the event date rather than post date. Post date makes sense for blogs but not really when the other date on your listing item take much greater priority. I am pretty sure that many users will use it. Any chance you could help?

1 Like

Unfortunately, there is no simple solution, it requires advanced customization. But it is possible to use the code snippet from this topic Change order of listings to random to start. If you are not familiar with code customization then please consider hiring someone for custom work

Also, we plan to add this feature in future updates

Please add Sorting feature for HivePress search, because WordPress hasn’t this feature by default for search and you must fix this issue for your HivePress plugin. It’s really necessary feature for search results. I’ve add new attributes and want HivePress show my attributes as default in search results but unfortunately it shows date by default.

1 Like


I know this thread is older than one year and I am not sure if this is a solution for you or anyone reading this, but lets give it a try :slight_smile:

In a non-listing website I use posts to show events which of course have dates in the future. So I manually set the post date to the event date and with the code below they are being published directly instead of scheduled, while the post order is reversed to show the upcoming events first.

Maybe you can (find someone to) customize the code so your custom date attribute is used to update the post date of listings? Not a clue if this could work, but I just wanted to share it :slight_smile:

remove_action( 'future_post',  '_future_post_hook' );

//Publish posts with future date
add_filter( 'wp_insert_post_data', 'do_not_set_posts_to_future' );
function do_not_set_posts_to_future( $data ) {
    if ( $data['post_status'] == 'future' && $data['post_type'] == 'post' )
        $data['post_status'] = 'publish';
    return $data;

//Reverse the post order
add_filter( 'pre_get_posts', 'reverse_post_order' );
function reverse_post_order( $query ) {
	if ( ! is_admin() && $query->is_main_query() ) {
		$query->set( 'order', 'ASC' );
1 Like