Skip Navigation

[Resolved] Sorting my repeating admin order

This thread is resolved. Here is a description of the problem and solution.

Problem:

I created a repeating view. I want the soft order on the website to be the same as the drag and drop order in the admin.

Solution:

You can try wpv_filter_query filter hook, like this:

https://toolset.com/forums/topic/sorting-my-repeating-admin-order/#post-2101945

Relevant Documentation:

This support ticket is created 3 years, 4 months ago. There's a good chance that you are reading advice that it now obsolete.

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.

Our next available supporter will start replying to tickets in about 8.95 hours from now. 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/Hong_Kong (GMT+08:00)

This topic contains 2 replies, has 2 voices.

Last updated by IntegrisDesign 3 years, 4 months ago.

Assisted by: Luo Yang.

Author
Posts
#2101713

Tell us what you are trying to do?

I created a repeating view. I want the soft order on the website to be the same as the drag and drop order in the admin. The function sorts based on the view id but also affects all the other pages as well. (For 12345 I placed the right ID of 8365)

Is there any documentation that you are following?

https://toolset.com/forums/topic/output-repeater-fields-in-their-drag-and-drop-order-in-wp-admin-edit-screen/

Is there a similar example that we can see?

add_filter( 'wpv_filter_query', 'order_rfg_by_wp_admin_sort', 199, 3 );
function order_rfg_by_wp_admin_sort( $query_args, $views_settings, $view_id) {
$view_ids = array( 12345 );
if (in_array($view_id, $view_ids)){
$args = array(
'meta_key' => 'toolset-post-sortorder',
'orderby' => 'meta_value_num',
'order' => 'ASC',
);
}
return array_merge($query_args, $args);
}

What is the link to your site?

hidden link

#2101945

Hello,

Please try to modify the PHP codes as below:

add_filter( 'wpv_filter_query', 'order_rfg_by_wp_admin_sort', 199, 3 );
function order_rfg_by_wp_admin_sort( $query_args, $views_settings, $view_id) {
	$view_ids = array( 12345 );
	if (in_array($view_id, $view_ids)){
		$args = array(
			'meta_key' => 'toolset-post-sortorder',
			'orderby' => 'meta_value_num',
			'order' => 'ASC',
		);
		$query_args = array_merge($query_args, $args);
	}
	return $query_args;
}

And test again

#2103247

My issue is resolved now. Thank you!