This thread is resolved. Here is a description of the problem and solution.
Problem:
The issue here is essentially the user has a post view and wanted to use that view to display the custom fields of the current post. This will require that they filter the view by the current post's id. Solution:
In order to filter by the current posts ID you will need to add a query filter to your view of the Post ID.
Select the option "Entries with ID defined by the view shortcode attribute:" and define your shortcode attribute.
Then you can add your view to your page like this.
[wpv-view name="my-view" ids='[wpv-post-id]']
Where the "ids" parameter is the shortcode parameter that you previously defined.
This support ticket is created 4 years, 11 months ago. 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.
Tell us what you are trying to do?
I'm trying to show a view in the child posts. The view works fine in the parent post, but in the child post, it doesn't find items.
What is the link to your site?
- Parent post showing the view (go to the section "Añádele un accesorio", at the bottom of the page): hidden link
- Child post not finding items for the same view: hidden link
More info of the case I think could help:
This type of post is in a many-to-many relationship with another type of post.
But this view it's showing only info from the custom fields (all of them the "Select" type) of the current post.
The filter I am using to display the view is "show elements in any relation to the Post where this View is shown." (sorry if it's not exactly as in the english toolset version, i'm using toolset in spanish). Maybe this is causing some trouble. In fact, I'm pretty sure I'm not using the filter correctly.
By the way, if I insert the html code used in the view directly in the template (managed by elementor) it works fine for parent and post child.
Maybe it's more correct to do it directly in the template, but the Elementor text editor widget is ugly and difficult to use for me. That's why I prefer to create a view (in your unicorn html editor interface) and insert the view widget in the template. Am I doing wrong?
Sorry if I don't explain myself very well, for me this is a little complex :/
Thanks in advance!
Yes. When I insert the code I used to build the view directly on the Elementor template (with the text editor widget), it works perfectly.
When I insert the Toolset view widget, the parents work well, the child posts don't find items.
Thanks for your quick response. As I say in my first message, this view is only showing info from the custom fields (all of them the "Select" type) of the current post. This view is not showing the child posts of the current post (maybe you think that because there's another view in the template showing the child/brother posts).
That's why I said that probably the best way to do what I want (show info from the custom fields) is inserting the shortcodes and the HTML directly on Elementor text widget. But changing anything it's a nightmare and I prefer your HTML editor.
In the parent post, the view show the info from the custom fields properly. In the child post, the view doesn't find the info.
Is there a way to do what I want via Toolset Views? Or should I forget about it because it's a bad practice?
This is why i'm confused. Have a look at my screenshot.
The view that is returning the no results found is the "Accesorios textil view". When I checked I see that it is checking for a post relationship.
However you are saying that "this view is only showing info from the custom fields (all of them the "Select" type) of the current post."
"This view is not showing the child posts of the current post (maybe you think that because there's another view in the template showing the child/brother posts)."
But this is not the case based on what i'm seeing as the relationship filter is for child posts.
"That's why I said that probably the best way to do what I want (show info from the custom fields) is inserting the shortcodes and the HTML directly on Elementor text widget."
Reading this clarifies a few things.
The filter that you need on the view is for post ID. So it will filter correct. Take a look at my screenshot for the post id filter.
Select the option "Entries with ID defined by the view shortcode attribute:" and define your shortcode attribute.
Then you just call the view in your elementor template with
That was exactly what I was searching for! Thanks a lot Shane!
I was pretty sure I was not using the filter right. When the view returns items not found, the first place I look is the filter options. But this time I was very lost, so thanks again! 😀