Saltar navegación

[Resuelto] Sorting my repeating admin order

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

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 4 years, 11 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.

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 -

Zona horaria del colaborador: Asia/Hong_Kong (GMT+08:00)

Este tema contiene 2 respuestas, tiene 2 mensajes.

Última actualización por IntegrisDesign 4 years, 11 months ago.

Asistido por: Luo Yang.

Autor
Mensajes
#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?

enlace oculto

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