Hi.
I need create a template with the same hierarchy drawn in the black image in attachment, with two multi-reference levels. It`s possible?
Thank you.
Hello, it looks like you have two one-to-many (O2M) relationships in a hierarchy like Municipios > Escolas > Enderecos. On the Municipio post template you want to display the related Escolas and their Enderecos posts in a nested list. This is possible in nested Views, but unfortunately it is not possible to create nested Views in a template using the Block Editor. You must enable the legacy Views editor to accomplish this, since nested Views are not supported yet in the Block Editor. Here is the general process:
1. Activate the legacy Views editor experience to create the nested View. Go to Toolset > Settings > General tab, and choose the "Editing Experience" option that enables both the Blocks editor and the legacy editor.
2. Edit the Municipios template. At the top of the screen, find the "View with: " menu. Select one Municipios post that has some related Escolas with related Enderecos posts. If you have not already created some related Escola and Enderecos content, you should create those posts first and add the required post relationships to link the Enderecos to the Escola, and relate the Escola to the Municipio. Then refresh the Municipios template editor and select the Municipios post at the top of the screen.
3. In the Municipios template editor, create a new View block to display all the related Escolas of the current Municipios post. Choose a simple loop style like unordered list. In the View loop block, insert a Single Field block to display the post title or post title with link. You should now see a list of all the Escolas related to the Municipios post you selected to "View with:". Save the template.
4. Go to Toolset > Views and create a new View. In the first popup, select "display all results" and give the View a title like "Enderecos related to the current Escola".
5. In the View editor, select the Enderecos post type in Content Selection. This View will display Enderecos posts.
6. Scroll down to the Query Filter area and add a new filter by post relationship / repeatable field group owner. Select the Escola - Enderecos post relationship, as related items of the current post in the loop.
7. Scroll down to the Loop Editor panel and click Loop Wizard. Choose a simple loop style like unordered list, and insert the Post Title or Post Title with Link field.
8. Save the View and note the View slug at the top of the View editor page.
9. Return to the Municipios template editor. In the View Loop block, insert a new Custom HTML block just below the Single Field block displaying the post title. In the custom HTML block, insert the View you just created with a shortcode like this:
[wpv-view name="your-enderecos-view-slug"]
Replace your-enderecos-view-slug with the slug of the Enderecos View you just created.
10. Save the template and visit the Municipios post on the front-end of the site. You should see a nested list of Escola and Enderecos posts related to the Municipio.
Once the lists are displaying the correct posts, you can go back to the View editor and use the Loop Wizard to add other content to the Enderecos lists, or you can edit he Escola View in the Municipios template to add other information to the Escolas list. Let me know if you have questions about this.
Perfect! Thank you very much.