[Resuelto] Toolset relationship fields arent being created
This support ticket is created hace 5 años, 5 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.
I am trying to create a relationship between two post types... In wordpress back-end I see the one-to-many relationship is working, but if I try and get a count of child post's it is returning zero, I can also not find the _wpcf_belongs_ record anywhere in the database which is normally there...
Hello. Thank you for contacting the Toolset support.
The forum link you shared as a reference is too old and was using the legacy relationship.
To count the number of child posts there are two ways, either you should go with views to display the count or use the post-relationship API method: toolset_get_related_posts()
For example:
global $post;
$child_posts = toolset_get_related_posts(
$post->ID, // the parent post
'relationship-slug', // replace the relationship slug
'parent', // no need to change
999, // the maximum number of results
0, // the offset
array(), // additional query arguments
'post_id', // return format
'child', // role to return
'',
'ASC'
);
$count = count($child_posts);
Thank you for the advise. Trying it now :).
Is this query resource intensive, I want to add it in a view to grab the total number's but if it pulls each post with it's meta info I can think if my list is 20 items and each item has 200 relationship items, it's going to get quite insane?