Skip Navigation

[Resolved] Display posts with same taxonomy as page

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

Problem:

Display posts on a page that share the same taxonomy term as the page itself (e.g., both are tagged with "Seattle").

Solution:

Create a View:

- Go to Toolset > Views.
- Create a new View called "Related Content."
- Select the post types (e.g., posts and pages) to display in the View.

Set the Query Filter:

- In the Query Filter section of the View, add a filter for the taxonomy (e.g., "Locations").
- Choose "Select posts with taxonomy:
Locations the same as the current archive page".

Add the View to the Template:

- Edit the archive page template in Toolset or your theme.
- Add the View block or shortcode to the template where you want the related posts to display.

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.

This topic contains 4 replies, has 1 voice.

Last updated by Robert 1 week, 1 day ago.

Assisted by: Christopher Amirian.

Author
Posts
#2792031

I have created a custom taxonomy called "Locations". This will be a list of cities and counties.

I am trying to figure out how I would display posts on a page that contain the same taxonomies. For example, I write a blog post about Seattle real estate and add the "Seattle" location taxonomy.

I have a page called "Seattle Homes" with the same taxonomy "Seattle". My intention is to have the page display the post with the same taxonomies.

#2792064

Christopher Amirian
Supporter

Languages: English (English )

Screenshot 2025-01-14 at 11.24.27 AM.png
Screenshot 2025-01-14 at 11.24.07 AM.png

Hi,

Welcome to Toolset support.

- Create a view on the page and select the post type that the custom taxonomy is created on.

- On the sidebar option you will see a section called query filter. Select that and from the list select the Taxonomy term option. For you it will be Location

- Then you will be presented either with the Seatle option or you can manually type it for the query and it will perform the result. (Screenshots are from my installation, so the name of the term is related to my case)

Thanks

#2792120

Thanks Christopher. That gets me closer but what I really need is a way to setup the view filter dynamically. I am going to have hundreds of pages and hundreds of posts.

This means that my view is actually going to sit in the theme template for certain pages rather than on the individual page. So my filter needs to be something like:
Display posts that have Locations the same as this Page's locations.

See attached image for example.

#2792121
Screenshot 2025-01-14 053524.png

Here is the image

#2792289

Christopher Amirian
Supporter

Languages: English (English )

Hi,

For that dynamic functionality, you need to find a way to provide value to the view.

You can use the URL Parameter option from the screenshot you provided. Then you need to use ?=term-name on URL to dynamically feed the term in question to the view.

For more information:
https://toolset.com/course-lesson/filtering-custom-lists-of-posts/

Thanks.

#2792370

I found a way to do this:

I created a view called "Related Content" and selected posts and pages. The Locations taxonomy I am using is available for selection in both posts and pages.

For filtering on the view, I used "Select posts with taxonomy: Locations the same as the current archive page". I then added the view to the archive page template and it works like a charm.

For example: I have a Location term called "Seattle". I then created posts and checked "Seattle" under the locations taxonomy and saved them. When I load the Seattle Archive page, only the posts that are checked "Seattle" display on the page.