I am trying to create a nested views situation.
- On a Page, I want a view which displays Blueprints (custom post type)
- Each Blueprint has a view which displays Posts which are Related to that Blueprint
I set up the many-to-many relationship and assigned posts to a test blueprint. On the Page, the view which displays Blueprints works fine. However, the view within each Blueprint which should display related posts, doesn't work. It just displays the No Items Found Text. Example here: hidden link (Postcolonial Theory, Race and Caste).
I did some testing and found that:
- the same Blueprint works just fine when I just view this one Blueprint, i.e. when it is not displayed as part of another view on the Page. Example here: hidden link
- the same Blueprint works just fine even if it is displayed as part of another view on the Page IF I change the Content Selection for that view to show a different custom post type (Events). Example here: hidden link (Feminist Philosophy).
I don't understand why
- the Blueprint view displaying related posts works fine - as long as it's not part of the Page view,
- or it works fine in the Page view - as long as it displays something else than related posts.
The view seems to now pull the right things, but it displays them underneath the box defined by the content template, not within it. The one above (feminist philosophy, displaying events instead of the related posts) is the way it should display.
I am also really confused by the whole block display vs. code view thing. Can't I just please have one thing throughout? I know you guys want to upgrade and lower the bar of access for people, but having multiple places some of which are in this or in that UI, then knowing how to do one type of setting in one UI but not in the other, it's just frustrating. For example, I have no idea now how to make the view you created have a loop style 'unformatted' not 'unordered list'. I started working with Toolset way back when there were no blocks and now I have all this old content that just won't translate easily into blocks...
The problem with this is that the view below is set to display events and not posts. hidden link
Is it that you'll like this view to display posts and not events ? It can be quite tricky to select the correct areas but the best way to navigate through the view sections is by using the Block navigation tool at the top left of the editor. See Screenshot
This will display all your blocks and all the sections attached to the block.
The link you sent is to a page that is separate from the issue at hand. That's the Events page, and it has a view that displays custom post type - event. I don't need it to display posts, it works fine as it is. Never had an issue with it 🙂
The page I have problems with, is the Reading Group Blueprints. As part of troubleshooting the issue, I used the events in the content selection of one of the Blueprints, but this was just as a test if displaying a view within a view works.
I would very much prefer to not edit the views or content templates in the block editor. Like I said, I started using Toolset way back and now I'd have to remake a lot of content to make it work in the blocks. Plus I'm using a lot of custom classes and stuff, it's just easier to see them in the code without the GUI.
I'm also not sure why you created a bunch of new views and content templates? I have views and templates already created that just needed fixing: Blueprints and Blueprint Items. I am not sure what to do with the display-related-posts and loop-item-in-display-related-posts now.
Anyway, I'm just confused. All I need is that the view 'Blueprint Items' that's in the Blueprint called 'Postcolonial Theory, Race and Caste', correctly displays the related posts while that Blueprint is a part of the view 'Blueprints' on the page 'Reading Group Blueprints'.
'The view seems to now pull the right things, but it displays them underneath the box defined by the content template, not within it. The one above (feminist philosophy, displaying events instead of the related posts) is the way it should display.'
This still seems to be the case.
Can you please also explain what is happening? I'd quite like to know, rather than just be given a solution, since this issue might come up again and I'd like to be able to solve it.
Basically what I did was to create the view here hidden link
Then setup the query filter for the Post Relationship. See Screenshot.
From there I added the view to the content template of the view that is listing out the Blueprints below. hidden link
The main problem is that when the view is added to the accordion it breaks. I suspect that this is due to the additional accordion CSS that is inside the view.
So you may need to rethink how the accordion is created.
So do you know why the other view which displays events rather than related posts, is not broken by the accordion? Is it the relation that breaks it? It would be useful to know if I'm to rethink the accordion, as now I don't know which part of the accordion is causing the problems.
Was this accordion custom made ? It is quite possible that the issue is just that the expected structure isn't valid when the view is added because the view will introduce additional HTML tags to the default structure of the accordion.
Perhaps you can look into the Boostrap Accordion. hidden link
This might be a more universal solution in your case.
Thank you, I'll have a look. Sorry for the late reply - I had a little misadventure in the meantime and I'm writing from a hospital. If that's OK, I'll just keep the topic open before I have a chance to test it with the Bootstrap accordion.
Thanks! I'm still bed-bound, but getting there 😉
I didn't change the accordion, because installing Bootstrap seems like quite a mission and I don't really need it for anything else since the block editor does all the same things already.
I have no idea how exactly, but it just started working when I remade the Blueprint content template in code rather than in the block editor, and simply added
[wpv-view name="display-related-posts" order="asc"]
into it. And now it works just fine. I have no idea why it didn't work when used via the visual editor but now it does. I think I will remake everything I did with the visual editor into the code editor versions, because it's just so much more reliable.