Skip Navigation

[Gelöst] Display parent data on a child post

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem:

Display parent post information, and the parent posts are in "Private" status.

Solution:

By default the Toolset post type relationship API doesn't return private posts, so it conduct the problem you mentioned above, in your case, I suggest you try to use filter hook "toolset_get_available_post_statuses" to allow private posts, for example:

https://toolset.com/forums/topic/display-parent-data-on-a-child-post/#post-1157573

Relevant Documentation:

This support ticket is created vor 5 Jahre, 11 Monate. 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.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

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)

Dieses Thema enthält 6 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von Luo Yang vor 5 Jahre, 11 Monate.

Assistiert von: Luo Yang.

Author
Artikel
#1155649

Tell us what you are trying to do? Display parent data on a child post

Is there any documentation that you are following?
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/

Is there a similar example that we can see?
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/

What is the link to your site?
versteckter Link

On the child content template i sue:

[types field='client-first-name' item='@client-client-portfolio.parent'][/types]

however the parent content is not displayed.

I do see the the child is connected to the parent in the child edit mode in the admin back-end.
please advise,
David

#1155736

I noticed that when i'm viewing the custom post as an Admin i can see the Parent Data in the child however when i'm a subscriber the data does not show.
please note that the end user create his own private posts. i assume he can see data from private parent and child post he created.

#1155749

I used:

[wpv-view name="client-portfolios"  item="@client-client-portfolio.parent"]

in the parent content template and i can see the list of children in the parent post as an admin user. however i can not see the list as subscriber who created the parent and child posts

#1155987

Hello,

I assume we are talking about this case
- one-to-many relationship between post types "client" and "client-portfolio"
- custom field "client-first-name" in post type "client"
- Use an subscriber user to create private posts: "client" post and related "client-portfolio" posts
- in a single "client-portfolio" post, display parent "client" post information:
[types field='client-first-name' item='@client-client-portfolio.parent'][/types]

I have tried above settings in my localhost with a fresh wordpress installation, it works fine.

Please check these:
1) Upgrade to the latest version of Toolset plugins, you can download them here:
https://toolset.com/account/downloads/

2) In case it is a compatibility problem, please deactivate other plugins, and switch to wordpress default theme 2017, and test again

3) If the problem still persists, please provide database dump file(ZIP file) of your website, also point out the problem page URL, I need to test and debug it in my localhost, thanks
https://toolset.com/faq/provide-supporters-copy-site/

#1157573

Thanks for the details, I can see the problem, since the "Clients" posts are setup as "Private" status, but by default the Toolset post type relationship API doesn't return private posts, so it conduct the problem you mentioned above, in your case, I suggest you try to use filter hook "toolset_get_available_post_statuses" to allow private posts, for example:
1) Make sure you are using the latest version of Toolset plugins
2) Add below codes into your theme file "functions.php":

add_filter('toolset_get_available_post_statuses', function($statuses){
	$statuses[] = 'private';
	return $statuses;
});
#1158547

My issue is resolved now. Thank you!

#1159204

You are welcome

Dieses Ticket ist jetzt geschlossen. Wenn Sie ein Toolset Kunde sind und Hilfe benötigen, eröffnen Sie bitte ein neues Support-Ticket.