I have a relation of posts: Make -> Model -> Version. These are CPT.
I have also created views for "make", "model" and "version".
The problem is that I do not know how to create link/relation to individual views based on saved post.
For example: I have post "Audi A4 B8" where "Audi" is the make, "A4" is the model, "B8" is the version. How to create in the post view "Audi A4 B8" links to:
view "brand" where will only "Audi"
view "model" where there will only be "A4"
view "version" where will only "B8"
The same principle should work links in the post eg "BMW Serie5 E60" or "Mercedes ClassE W210",...
I will be grateful for the help or suggestions.
Hi, we have a couple of guides you can use to access information about parent, grandparent, and other ancestor posts:
https://toolset.com/documentation/user-guides/displaying-fields-of-parent-pages/
https://toolset.com/documentation/user-guides/displaying-fields-grandparents/
To link to a parent, you can use the "id" attribute in a wpv-post-link shortcode:
[wpv-post-link id="$model-type-slug"]
For grandparents, grand-grandparents, and so on, you must create Content Templates that can be used to access ancestor information. Let me know if you have additional questions about this.
Sorry for the delay with the response.
Links seem to work well. But I can not set views. I'm working on it.
And in connection with the topic of https://toolset.com/forums/topic/ctp-relationships-in-dropdowns/ can any additional problems occur?
And in connection with the topic...can any additional problems occur?
If a post has no parent, and you try to access its parent in a shortcode, you will see information from the current post instead. For example, let's say you add some code to Post 1. This post does not have a parent post. Let's say you include this code in Post 1:
[wpv-post-link id="$parent"]
When you look at Post 1 on the frontend, you will see the link to the child post, Post 1. If you want to hide this link instead of showing the child post link, you must use conditional code that tests the ID of the current post against the ID of the parent post. If they are the same, this post has no parent. If they are different, this post has a parent.
[wpv-conditional if="( '[wpv-post-id]' eq '[wpv-post-id id='$parent']' )"]
this post has no parent, so do not display the link
[/wpv-conditional]
[wpv-conditional if="( '[wpv-post-id]' ne '[wpv-post-id id='$parent']' )"]
this post has a parent, so display the link: [wpv-post-link]
[/wpv-conditional]
It's something that confuses many people, because they think that if the $parent does not exist, the link will not be shown. This is not the case. You must use conditional code.
I can not handle the parent display correctly in "make", "model", and "version" views. Please, you can take a look at what I'm doing wrong.
hidden link - make
hidden link - model
hidden link - version
And I have more and more concerns as to how it will work in the context of the https://toolset.com/forums/topic/ctp-relationships-in-dropdowns/
I started in the Wersja View, and noticed that it was displaying incorrectly. I'm not sure why, but I was able to edit the Content Selection and save it, then restore it to Osobowe, and now it is showing the proper posts.
Wersja View here:
hidden link
See the View displayed here:
hidden link
I see one problem I would like to mention in all 3 Views. See this code:
[wpv-layout-start]
[wpv-items-found]
<!-- wpv-loop-start -->
<div class="offers-tools">
<h1>Pojazdy osobowe - [wpv-post-title]</h1>
In this case, wpv-post-title does not show the title of the Osobowe post, it displays the title of the current post. In the case of the test page above, the current post title is the page, and the page title is "Test". So I don't think you will see the expected post title this way. To show the title of the post in the Loop, you must move the wpv-post-title shortcode into the Loop, between the wpv-loop tags.
And I have more and more concerns as to how it will work in the context of the https://toolset.com/forums/topic/ctp-relationships-in-dropdowns .
I would like to help address these concerns, but I would also like to keep this ticket focused on the link issue. Please open separate tickets so we can address these concerns while keeping the forum organized. Thank you for understanding.
I have the impression that we do not understand.
I want to see the posts same as the "Person", not the list of posts of posts.
Please visit screen "make-model-version.jpg".
Thank you.
1. See error.png. I fixed an error message in your View here:
hidden link
/auto-box/osobowe-marka/audi/
The ancestors argument does not end with a valid parent for the returned post types on this View.
It appeared to be related to this filter:
[wpv-control-post-ancestor type="select" default_label="Wersja" format="%%NAME%% <span>(%%COUNT%%)</span>" ancestor_type="osobowe-wersja"]
Post type "Osobowe" does not have a parent post type called Osobowe Wersja, so this filter was failing. I have updated this filter to remove the Wersja parent, and the error is no longer displayed. Please apply the same changes to your other Views if needed.
2. See query-filter.png. I believe the Query Filter for this View was incorrect:
hidden link
I believe the Query Filter should be set to "Select posts that are children of... Post where this View is shown", because you want to show Osobowe posts that are children of the "Audi" Osobowe Marka, correct? I have made this change, but you should probably apply similar changes to your other Views as needed.
3. The post body shortcode was pointing at the "make" instead of the Osobowe. See post-body.png. This is not correct:
[wpv-post-body id="$osobowe-marke" view_template="Loop item in Ogloszenia - osobowe"]
You should not use the ID attribute here to point at the Make. The View finds Osobowe, and you want to display information about the Osobowe. I have made this change here, but you will probably need to apply similar changes to your other Views.
Please apply changes as needed to your other Views, and let me know the results.
It works great!
Thank you so much for your help and clarification.