Skip Navigation

[Resolved] show fields from a post relationship

This thread is resolved. Here is a description of the problem and solution.

Problem:

Display related posts information by many-to-many relationship.

Solution:

You can follow our document to display the related posts information:

Relevant Documentation:

https://toolset.com/course-lesson/displaying-related-posts/#displaying-many-related-items

This support ticket is created 3 years 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 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 9 replies, has 2 voices.

Last updated by davidS-72 3 years ago.

Assisted by: Luo Yang.

Author
Posts
#2258477
toolset_content_template_edit.jpg
toolset_relationship_coleccs-publicacions.jpg

Tell us what you are trying to do?
I've a relationship with CPTs "publicacio" and "coleccs", something like books and authors. I want to show the author name(coleccs) in the single page for publicacio (book).

When I put in the "content template " a toolset single field, in the source I can't see the "Parent: <post type name> option"

Is there any documentation that you are following?
https://toolset.com/lesson-placement/lesson-placements-1824625-1727273/
https://toolset.com/course-lesson/using-post-reference-field-to-set-up-one-to-many-relationships/

Is there a similar example that we can see?
relation like books and authors

#2258847

Hello,

I assume we are talking about many-to-many relationship between post types "publicacio" and "coleccs", one "publicacio" post can connect with multiple "coleccs" posts, in the single "publicacio" post, you can follow our document to display the realted "coleccs" posts information:
https://toolset.com/course-lesson/displaying-related-posts/#displaying-many-related-items

#2259193

Yes, the relationship is many to many (Coleccs [*] << Coleccs Publicacions >> Publicacions [*])

In the tutorials when creates a single page for a CPT appears the related CPT, but I can't see it and then I can't use the "coleccs" fields values to show it in the page.

I've made a video for you:
hidden link

thanks

#2259827

Thanks for the video, in the content template you mentioned in the video, you can add a view block:
- Query "coleccs" posts
- Filter by post type relationship between "publicacio" and "coleccs"
- In view's loop, display the "coleccs" information(custom fields)

See the document I mentioned above:
https://toolset.com/course-lesson/displaying-related-posts/#displaying-many-related-items
Section "Displaying many related items"

If you need more assistance for it, please provide a test site with the same problem, I can setup a demo for you

#2260599

It needs a child post view, I have done below modifications in your website:
1) Dashboard-> Toolset-> Views
Create a new post view "show fields from a post relationship":
hidden link
- Query "Col·leccions" posts
- Filter by:
Select posts in a Publicacions Col·leccions relationship that are a related to the current post in the loop.
- In view's loop, display "Col·leccions" post link

2) Edit the home page,
hidden link
In view's loop, display above post view

Test it in frontend, it works fine:
hidden link

Please check if it is what you want, thanks

#2260967

Hi Lou,
you have done this with a view, but as I explain in the single page I need this field as a "inline field", not a view, to use it inside a paragraph.
I need to can use the fields as follows:

1) The collection [FIELD COLLECTION NAME] includes the book [FIELD PUBLICACIÓ NAME] number [FIELD PUBLICACIO NUMBER] etc...
2) in the home page, Col·lecció : [FIELD COLLECTION NAME] , in a line no as a list.

thanks,

#2262403

I have done below modifications in your website:
1) Edit the post view "show fields from a post relationship"
hidden link
a) In section "Loop Editor", click button "Loop Wizard", choose option "Unformatted", and display the post title:

		[wpv-item index=1][wpv-post-body view_template="loop-item-in-show-fields-from-a-post-relationship"]
		[wpv-item index=other], [wpv-post-body view_template="loop-item-in-show-fields-from-a-post-relationship"]

you can add other post fields into the content template "Loop item in show fields from a post relationship"
b) enable option "Disable the wrapping DIV around the View"

2) Edit the page "Home", find and edit the view block, after text "Col·lecció:", display above post view's shortcode:
[wpv-view name="show-fields-from-a-post-relationship"]

Test it in frontend:
hidden link
It works fine, and display the the post view as inline text

It is only a demo for your reference.

More help:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-view
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-item

#2262729
Captura de pantalla 2022-01-10 135424.jpg

Thanks Lou, this is better but the field is still out of paragraph and this causes a new line as you can see in the home page (I've changed from 3 columns to 1 column to show the issue).

I would like to use the button "inline field". Please look the attached image.
Is this possible with a field in a CPT relationship?

#2263195

Thanks for the screenshot, I have done below modifications in your website, edit the home page:
hidden link
Replace the paragraph block with a custom HTML block, with the same code:

ol·lecció: [wpv-view name="show-fields-from-a-post-relationship"]

It should be able to remove the extra paragraph.

For the button "inline field", it won't work for many-to-many relationship, it only work for one-to-many or one-to-one relationships

#2263461

My issue is resolved now. Thank you!