Skip Navigation

[Closed] Disable sorting for Search (WordPress Archives)

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 4 replies, has 3 voices.

Last updated by Nigel 6 months ago.

Assisted by: Waqar.

Author
Posts
#2658781

I'm currently using Toolset Block Editor to style my search results through the WordPress Archives functionality. However I can't find a way to disable sorting of the results and this is messing up the results order. Is there an option to disable sorting from Toolset's end or a field that can be used that won't change the order being passed on to Toolset?

#2659015
sorting-controls.png

Hi,

Thank you for contacting us and I'd be happy to assist.

If you'd like to remove the front-end sorting controls, you can delete the block 'Sorting Controls' from the archive's blocks.
( example screenshot attached )

We also have guide on this topic at:
https://toolset.com/lesson-placement/lesson-placements-1621271-1622285/#add-front-end-sorting-to-an-archive

regards,
Waqar

#2659065
SortingOptions.png

I might not have explained myself well. What I need to omit are the ordering options (even if this has to be done through functions.php). The results are being passed on by another plugin but then are being sorted/ordered by Toolset before being displayed (not on front-end).

#2659439

Thank you for sharing this information.

Can you please share the name of the plugin that you're using to control the order of the posts? I'll test it on my website and suggest the next steps accordingly.

#2686832

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

The client shared their solution using the API to modify the query sorting (linked to their use of another plugin they intend to influence the sorting):

Just in case anyone needs an answer to this, it has to be done programmatically by using the wpv_filter_query filter for views and the pre_get_posts action for archives as per examples below:

For particular views
==================

add_filter( 'wpv_filter_query', 'override_display_order, 101, 3 );
function override_display_order( $query_args, $view_settings, $view_id ) {

//use original order
if ( $view_id == 1) { //replace with your view ID
$query_args['orderby'] = 'post__in';
}

return $query_args;
}

For archives - example search archive
================================

add_action('pre_get_posts', 'custom_archive_query');
function custom_archive_query($query){
if(is_admin() || !$query->is_main_query()){
return;
}

if( is_search() ) {
$query->set('orderby','post__in');
}
}

The topic ‘[Closed] Disable sorting for Search (WordPress Archives)’ is closed to new replies.