Passer la navigation

[Résolu] Sorting my repeating admin order

Ce fil est résolu. Voici une description du problème et la solution proposée.

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 Il y a 4 years, 11 months. 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.

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 -

Fuseau horaire du supporter : Asia/Hong_Kong (GMT+08:00)

Ce sujet contient 2 réponses, a 2 voix.

Dernière mise à jour par IntegrisDesign Il y a 4 years, 11 months.

Assisté par: Luo Yang.

Auteur
Publications
#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?

lien caché

#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!