Navigation überspringen

[Gelöst] Sorting my repeating admin order

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

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 vor 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 -

Zeitzone des Unterstützers: Asia/Hong_Kong (GMT+08:00)

Dieses Thema enthält 2 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von IntegrisDesign vor 4 years, 11 months.

Assistiert von: Luo Yang.

Author
Artikel
#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?

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