I hope I'm not asking a CSS question disguised as a toolset issue but here is the problem:
I've created a list group display of custom posts. Everything looks fine as you can see from this link:
hidden link
If I replace the words "Display related Post" with a view that displays a related post for each of the posts in the loop of the main view on that page, it breaks the layout. The first two items in the list displays mostly correctly but then every other item has extraneous p tags, which breaks the layout. Since that happens only after inserting a toolset view, I assume it is related to toolset. What is the solution?
Hello, it's hard for me to say exactly what could be happening without being able to see the results with the nested View in place. It's possible that there is a problem in the nested View that produces invalid HTML markup, which then causes a cascading problem with all the content below that corrupted markup. That's where I would start my investigation, to see if there is something like a missing closing div tag or other obvious error in the loop. It's also possible that some dynamic content in that nested View contains such invalid HTML markup. You could try to rule that out by replacing the contents of the loop with something simple, like a wpv-post-title shortcode, to see if the problem is resolved. Then replace the previous contents piece by piece, testing each time, until the problem returns. That might help narrow down the source of any invalid HTML markup produced by dynamic content.
If this doesn't seem to help, or if you'd like for me to take a closer look, please provide login credentials in the private reply fields here. Let me know which View you are attempting to nest inside the main View, and I will give you some feedback.
Christian: Thank you.Based on your suggestions, I tried replacing it with wpv-post-title, and that resolved the html issues. That led to an experiment that resolved it.
I was using this markup in the nested view that displays the related post:
[wpv-items-found]
<!-- wpv-loop-start -->
<wpv-loop>
[wpv-post-body view_template="loop-item-in-my-nested-view"]
</wpv-loop>
<!-- wpv-loop-end -->
[/wpv-items-found]
[wpv-no-items-found]
I then had put the actual fields from the related post in the content template window below the view (the "loop-item-in-my-nested-view" template) . There was no other markup in that content template; just the field ( I.e.
[types field="actionmodified"][/types]
)
What fixed it was deleting the content template shortcode in the view loop and simply inserting the field shortcodes directly into the loop. Was I doing something wrong in doing it the first way? Or was this some quirk of my layout?
Okay I see what you mean, thank you for the additional information. It is perfectly acceptable to use a template like this in the loop of a View, so you weren't doing anything inherently wrong. It is never required that you use a template to consolidate the loop code contents, just a matter of preference. I usually bypass the template step if the loop structure is simple/straightforward, like the example you shared. On the other hand, if the loop generates a grid, uses pad, pad-last, wrap, or index/item, or is otherwise more complex, the reusable template makes more sense and is easier to maintain than duplicated blocks of code for each index/item.
If the problem was resolved by moving the contents out of the template and directly into the loop, the issue could be a theme or 3rd-party process is hooking into the_content somehow and modifying the output. Toolset's Content Templates are closely tied to the functionality of the_content in WordPress, so 3rd-party processes that hook into the_content may influence the rendered template results.
In that case, consider these two options:
1. Move the contents directly into the loop and drop the template shortcode, as you have already explained and implemented. This is usually practical when the loop has a simple repeating structure.
2. Disable 3rd-party filters in the template by adding the suppress_filters attribute to the template shortcode, like so:
[wpv-post-body view_template="loop-item-in-my-nested-view" suppress_filters="true"]
That attribute is documented here: https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-post-body. This approach is more practical when the loop structure is complex, and would require repeating code for each index/item in the loop structure.
That's very helpful, as usual. Thank you so much!
My issue is resolved now. Thank you!