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!
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.
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?
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?
It turns out it was user error, we got it resolved. Thank you so much!