Skip Navigation

[Resolved] get related post

This support ticket is created 3 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 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 4 replies, has 2 voices.

Last updated by federicoA 3 years, 11 months ago.

Assisted by: Shane.

Author
Posts
#1616727

Hi,
I have the following custom posts:
designer
collections
products.

Relations
Designer one by one with collections
Collection one to many with products

In the single-collections.php I have to recover the designers and the associated products (with the galleries).
I am reading the document
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_post
 
but I don't understand it.
To do a test I tried
<? php $ deisgner = toolset_get_related_post (get_the_ID (), array ('collections', 'designers')); ?>

but I have no data.
You can help me?

Thanks

#1617409

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Federico,

Thank you for getting in touch.

This should work and return the ID of the Designer.

Could you allow me to have admin access to the website as well as a link to one of the pages and the page template so that I can have a look at this for you ?

The private fields will be enabled for your next response.

Thanks,
Shane

#1620085

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Federico,

If I understand correctly, you want to list out all the designer that is related to this collection here
hidden link

So using the toolset_get_related_posts() function you want to return all of the product collection posts correct?

Please let me know and we can go from there.

Thanks,
Shane

#1623523

Hi Shane,
in single-collections.php I have to:
- view the designer of the collection
- view all the products of the collection
- for each product I have to display the custon fields (gallery, colors, height, width, weight, ...)

thanks
Federico

#1624039

My issue is resolved now. Thank you!

I used the function toolset_get_related_posts like this:
$products = toolset_get_related_posts( $product, 'prodotto-collezione', 'parent');
$designer = toolset_get_related_post( get_the_ID(), 'designer-collezione', 'parent');

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.