I have a CPT called "Articles" and another CPT called "Magazines".
Some articles are standalone articles, and some are children to magazines in a many-to-many relationship.
I can easily display a list of articles that relate to a certain magazine. please check the unordered list at the bottom of this post:
hidden link
now I want to add a view to the "articles" layout to show a link back to the parent magazine, but only when the article is a child to a magazine.
I was able to achive something similar between another pair of CPTs (books and chapters) using this code:
[wpml-string context="Chapters Parent book title" name="Chapters Parent book title"]This is a Chapter of the Book: [/wpml-string][wpv-post-link id='@book-chapter-one-to-many.parent'].
However, this will always show in the layout as there are no chapters that are not related to books, but for articles/magazines you can have standalone articles and magazine related articles.
So my question is: how to create a view to show parent magazine only when the article is related to a magazine only?
If i used my code above, then on standalone articles, i will have a meaningless sentence appearing saying: "this article is a part of magazine: (nothing)."
Thanks a lot.
Hello,
You just need to move the text "this article is a part of magazine..." into the related magazine post view, for example:
1) Create a post view, list magazine posts, filter by the
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/#displaying-many-related-items
2) In "Loop Output" section, insider shortcode [wpv-items-found]... [/wpv-items-found], display the text "this article is a part of magazine...".
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-items-found
Meta HTML wrapped in [wpv-items-found][/wpv-items-found] will be output if there are any posts | taxonomies | users returned by the View.