Skip Navigation

[Resolved] Child post is not showing a view

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, 3 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.

Our next available supporter will start replying to tickets in about 2.06 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 10 replies, has 2 voices.

Last updated by pabloQ-2 4 years, 3 months ago.

Assisted by: Shane.

Author
Posts
#1463703
vieweditor-1.jpg
loopeditor.jpeg
filter.jpg

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!

#1464045

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Pablo,

Thank you for getting in touch.

You say it works fine when you insert the shortcode directly into the elementor template correct?

However it doesn't work when you use to view block to insert it into elementor correct?

Please clarify for me.

Thanks,
Shane

#1464071

Hi Shane,

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!

#1464467

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Pablo,

Would you mind allowing me to have admin access to the website so that I can have a look at this for you ?

The private fields will be enabled for your next response.

Thanks,
Shane

#1464469

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

private fields

#1469871

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Pablo,

I took a look at this for you and it seems to be working fine.

Have a look here .
hidden link

I've added the view to the bottom of the page again and it works fine. Both ways of inserting the view works fine.

Only if you're in the preview it will show as no items found, but on the frontend it works fine.

Thanks,
Shane

#1470719

Hi Shane,

Yes, it works on parent posts, like the one you are linking. But in the child posts like hidden link

You will see the message "Sin items" ("Without items"). This is the string I put in the view loop between the not items found brackets.

Can you take a look at this?

Thanks!

#1471217

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Pablo,

If you look at the post you sent previously. You will see that this post has no child posts attached to it.
hidden link

If there isn't a child post attached to the post then the view will display "No Items Found".

Thanks,
Shane

#1471277

Hi Shane,

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?

Thanks!

#1471433

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Screenshot 2020-01-21 at 10.10.44 AM.png
Screenshot 2020-01-21 at 10.05.45 AM.png
Screenshot 2020-01-21 at 10.05.40 AM.png

Hi Pablo,

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



[wpv-view name="accesorios-textil-view" ids='[wpv-post-id]']

Thanks,
Shane

#1471465

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! 😀

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.