Skip Navigation

[Resolved] Display fiction or non-fiction parent post values

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 6 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 4 replies, has 2 voices.

Last updated by christineC 6 years, 11 months ago.

Assisted by: Christian Cox.

Author
Posts
#607396
Screenshot 2018-01-17 20.45.54.png

Trying to display the author of a non-fiction book, or the author of a fiction book in the same view. Currently I have:

Live: Authors - > Book (Fiction or Non fiction, separate post types with the same parent) -> Additional book info
So: Grandparent($authors) -> parent($fiction or $non_fiction) -> current post (additional info)

Inside of each post in additional book info, I have followed the rules to get the book author as a grandparent item per https://toolset.com/documentation/user-guides/displaying-fields-grandparents/ :

View on additional info post: [wpv-post-body id="$fiction" view_template="get-author-grandparent"]

Content template: [wpv-post-link id='$authors']

Ideally, to get the additional info page to pull either fiction or non-fiction authors based on whether a relationship is null or not, the code would look something like:

[wpv-conditional if="((empty($(_wpcf_belongs_fiction_id))))"]
[wpv-post-body id="$non_fiction" view_template="get-author-grandparent"]
[/wpv-conditional]

[wpv-conditional if="((empty($(_wpcf_belongs_non_fiction_id))))"]
[wpv-post-body id="$fiction" view_template="get-author-grandparent"]
[/wpv-conditional]

So on this fictional work, the author's name is correct: hidden link

But on this non fiction post child, the author is incorrect because it's looking for a fiction relationship author, not non-fiction: hidden link (parent non fiction post hidden link)

Any help is appreciated, thanks!

#607654

Hi, I don't see anything inherently wrong with this logic, so I suspect there is something else going on. Please add debug="true" to turn on debugging for these conditionals, then copy + paste the evaluation output for me to review:

[wpv-conditional if="((empty($(_wpcf_belongs_fiction_id))))" debug="true"]
[wpv-post-body id="$non_fiction" view_template="get-author-grandparent"]
[/wpv-conditional]

[wpv-conditional if="((empty($(_wpcf_belongs_non_fiction_id))))" debug="true"]
[wpv-post-body id="$fiction" view_template="get-author-grandparent"]
[/wpv-conditional]

Please include the debug information from both a fiction and a non-fiction example.

#607658

Great, thanks.

I put it in and the only issue is that both values show up on either page, so fiction tries to get the fiction author and does so successfully: hidden link; but not before it tries to get the non_fiction author

Conversely, a non-fiction book does the same thing...just in the opposite order (hidden link) – perhaps I just need to find another way of using the conditional tags?

#607764

I'm still quite lost, sorry! Please answer these questions in detail:
1. What is wrong with this page: hidden link , and why? Tell me all the parents and grandparents of this Additional Info post.

2. What is wrong with this page: hidden link , and why? Tell me all the parents and grandparents of this Additional Info post.

3. Can a single Additional Info post have both a Fiction and a Non-Fiction parent?

4. If yes, which one's parent Author should be shown on each of the Additional Info posts above, and why?

#610119

It turns out it was user error, we got it resolved. Thank you so much!

The forum ‘Types Community Support’ is closed to new topics and replies.