Skip Navigation

[Resolved] Post relationship and taxonomy views and archives

This thread is resolved. Here is a description of the problem and solution.

Problem: I have a custom post type Destinations and a custom taxonomy Destination Types. I have another custom post type Stories that are child posts of Destinations.

On the Destination Type taxonomy archive page, I would like to show:
- A list of Destinations associated with this Destination Type
- A list of the child Stories of these Destinations

Solution:
- Create a WordPress Archive for the Destination Type taxonomy. Set this archive to only display Destination posts.
- In the Loop Output wpv-loop tags of this WordPress Archive, build the design that corresponds to the Destinations list
- Create a new View of Story posts (I will call this View #1), filtered by post relationship, where the post parent is the current post in the loop.
- In the Loop Output editor, you will build the design the corresponds to the Stories list. For now, you can simply insert a wpv-post-title shortcode in the wpv-loop tags to confirm things are working correctly.
- Create a new View of Destination posts, filtered by Destination Type taxonomy, where the taxonomy term is set by the current archive page. I will call this View #2.
- In the Loop Output editor of View #2, insert View #1 in the wpv-loop tags. Now you have nested View 1 inside View 2, resulting in a list of stories about each destination.
- Insert View #2 in the WordPress Archive, outside the wpv-loop tags, but still inside the wpv-items-found shortcode.

Relevant Documentation:
https://toolset.com/documentation/user-guides/create-custom-taxonomies/
https://toolset.com/documentation/user-guides/creating-wordpress-custom-post-archives/
https://toolset.com/documentation/user-guides/filtering-views-by-taxonomy/

This support ticket is created 5 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.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 3 replies, has 2 voices.

Last updated by doronN-2 5 years, 11 months ago.

Assisted by: Christian Cox.

Author
Posts
#904510

I have a CPT "Destination" that represent a tourist destination (i.e a Destination somewhere in the world).
Destination CPT has a custom taxonomy - Destination Type. i.e beach, classic Europe, nature etc.

I have another CPT "Story" that represents a story about that destination. For example, Rio De Janeiro is a beach destination, it has several Stories.

I set Story To be a child of Destination -the logic is: "a Destination has stories".

I need to set the Destination Type taxonomy page layout so that it shows first, several destinations with that taxonomy, plus a list of stories that are connected to Destinations with that taxonomy. For example:
--------------------------------------------------
Title: Beach Destinations

San Francisco | Tel Aviv | Rio De Janeiro

Story about Rio De Janeiro
Story about Rio De Janeiro
Story about Tel Aviv
Story about San Francisco
---------------------------------------------------

Is it possible? and if so - can you point me to the proper resources?
I need to set one template so that each Destination Type will look and behave the same.

Thanks!

Doron

#904556

Hi, you can accomplish this with a combination of WordPress Archives and Views. Here's how I would approach it.
- Create a WordPress Archive for the Destination Type taxonomy. Set this archive to only display Destination posts.
- In the Loop Output wpv-loop tags of this WordPress Archive, build the design that corresponds to this part of your proposed design:
San Francisco | Tel Aviv | Rio De Janeiro
- Create a new View of Story posts (I will call this View #1), filtered by post relationship, where the post parent is the current post in the loop.
- In the Loop Output editor, you will build the design the corresponds to this part of your proposed design:
Story about Rio De Janeiro
Story about Rio De Janeiro
...etc...
For now, you can simply insert a wpv-post-title shortcode in the wpv-loop tags to confirm things are working correctly.
- Create a new View of Destination posts, filtered by Destination Type taxonomy, where the taxonomy term is set by the current archive page. I will call this View #2.
- In the Loop Output editor of View #2, insert View #1 in the wpv-loop tags. Now you have nested View 1 inside View 2, resulting in a list of stories about each destination.
- Insert View #2 in the WordPress Archive, outside the wpv-loop tags, but still inside the wpv-items-found shortcode.

#905487

Thank!

Took me a while to figure out, but it works!

#924168

Hey
Reposting a followup question:
We ended up using a many to many relationships i.e a destination has several stories and a story can relate to several destinations. For example, the story "10 grate hotels Israel" can be related to (Destination) Jerusalem and Tel Aviv.
Took (the very useful) steps you describe in your answer, but because the relationship is now many to many, ended up with:

Beach destinations
Cancun| Isla Mujeres

10 beach hotels in Mexico
Good places to eat in Mexico
10 beach hotels in Mexico

The "10 beach hotels in Mexico" is associated with Cancun and Isla Mujeres so it apres twice..

Is there a way to prevent this duplicity?

Thanks!

Doron

New threads created by Christian Cox and linked to this one are listed below:

https://toolset.com/forums/topic/prevent-duplicate-results-in-views-of-m2m-posts/

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