Skip Navigation

[Resolved] get related post

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.

Tagged: 

This topic contains 4 replies, has 2 voices.

Last updated by federicoA 1 year, 8 months ago.

Assigned support staff: 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');