Skip Navigation

[Resuelto] Ordering repeatable field group custom fields by Toolset sort order not working

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

Problem:
Ordering repeatable field group custom fields by Toolset sort order not working

Solution:
You should use the Toolset post relationship API fuunction toolset_get_related_posts() to display the repeating field entrines in specific order either ASC or DESC.

You can find the proposed solution, in this case, with the following reply:
=> https://toolset.com/forums/topic/ordering-repeatable-field-group-custom-fields-by-toolset-sort-order-not-working/#post-1241342

Relevant Documentation:
=> https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts

This support ticket is created hace 5 años, 6 meses. 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

Este tema contiene 2 respuestas, tiene 2 mensajes.

Última actualización por kasiaG hace 5 años, 6 meses.

Asistido por: Minesh.

Autor
Mensajes
#1241331
Screen Shot 2019-05-08 at 11.50.00 PM.png
Screen Shot 2019-05-08 at 11.47.40 PM.png

I am trying to get a list of buy links to output according to the sorted order on the post, and not by the order in which they were added to the post. Here is my code:

$buy_links = toolset_get_related_posts( 
  get_the_ID(), 
  'buy-links', 
  array( 
    'query_by_role' => 'parent',
    'return' => 'post_object',
    'orderby' => 'toolset-post-sortorder',
    'order' => 'ASC' ) );

What am I doing wrong? It is still outputting them in the order I added them and not my sorted order. I've attached screenshots to help illustrate the issue.

#1241342

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - can you please try to use the following code and try to resolve your issue:

$buy_links  = toolset_get_related_posts(
 get_the_ID(),     // the parent post
'buy-links',   // the RFG slug
'parent',     // the RFG role in this relationship is 'child'
100,     // the maximum number of results
0,           // the offset
array('meta_key'=>'toolset-post-sortorder'),     // additional query arguments
'post_object',   // return format
'child',    // role to return
'meta_value_num',
'ASC'
);

More info:
=> https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts

#1241345

Worked perfectly. Thank you very much.