Skip Navigation

[Resolved] Show Tour on the relevant country pages

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

Problem: I have CPTs Tours and Countries, and I have a custom taxonomy TourCategories. Each Country post is represented as a term in the TourCategories taxonomy, and Tours related to each Country are assigned the matching TourCategory term. I would like to show a View of Tours associated with the current Country on the single Country post.

Solution: Create a View of Tours filtered by TourCategory term, where the term is set by the current post slug. Insert the View of Tours in a Content Template for the Country post type.

Relevant Documentation: https://toolset.com/documentation/user-guides/passing-arguments-to-views/
https://toolset.com/documentation/user-guides/filtering-views-by-taxonomy/

This support ticket is created 6 years, 7 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 17 replies, has 2 voices.

Last updated by SimonB1420 6 years, 7 months ago.

Assisted by: Christian Cox.

Author
Posts
#710314

Hi

I made a video on two questions, please watch hidden link excuse all the um's

1. Showing tours view on the country page, where the tours are in those countries, without having to create a filtered view per country.

2. Use a field with comma separated data in a views list.

This is the website hidden link

Thanks
Simon

#712095
queryfilter.png

Hi, may I kindly ask you to create separate tickets for each question in the future? This helps us keep the forum organized, and helps others find answers to similar questions more efficiently. Thanks for your help!

1. If the slug of the Odyssey World Country post "Botswana" is identical to the slug of the Odyssey World Category term "Botswana", and the same is true for all the other O.W.Country post slugs and O.W.Category term slugs, then this is fairly straightforward. Create a View of all O.W. Tour posts and add a Query Filter, filtered by O.W.Category taxonomy term, where the term slug is set by a shortcode attribute. See queryfilter.png for an example. My taxonomy is "book-tax" and my attribute is "wpvbooktax" but your taxonomy will be something else, and your attribute can be something else. The attribute is arbitrary, but should only be lowercase letters for simplicity.

Then to specify the filter, pass the current page's slug into the shortcode attribute like this:

[wpv-view name="your-tour-view-slug" wpvbooktax="[wpv-post-slug id='$current_page']"]

This technique is called passing arguments into a View, and is explained in more detail here: https://toolset.com/documentation/user-guides/passing-arguments-to-views/

To further automate this so you don't need to insert the View in each Country post, you need to insert the View in a Content Template. Then apply that Content Template to all Country posts. More about Content Templates:
https://toolset.com/documentation/user-guides/editing-view-templates/

2. There's not an easy way to set up a View that loops over a single comma-separated text string like this, and if features are not encoded as separate options in a custom field then there's no good way to filter a custom search View based on features.

If custom searches filtered by features aren't important, then you may be able to create a new custom post type "Features" and add each possible feature as a custom post in that post type. Then it may be possible to configure the import process to map those feature names with feature post IDs. A comma-separated string of numeric IDs could be used as a View's post ID filter using a shortcode attribute like I mentioned above. A comma-separated string of text isn't quite as reliable as a comma-separated string of numeric IDs, which would be less likely to change over time.

If you have additional questions about comma-separated lists, please feel free to open a separate ticket so we can discuss in more detail.

#720018

Hi

Totally being thick on this sorry, created another vid here hidden link

Although it helps to see the png file on here as the email did not, I still want you to see the video to check it is an option. Or if you need to see more?
Thanks
Simon

#720590

I think you're caught up on the Tour slugs, which are not relevant to what I'm describing. On the Botswana OWCountry post you showed, the slug of the OWCountry is "botswana" - I can see it in the URL. If I understand correctly, OWTour posts that are associated with the OWCountry Botswana have the taxonomy term "Botswana" from the OWCategory taxonomy. Correct so far?

So my question is - are the slugs of the OWCountry posts (like Botswana, Lesotho, Burundi, etc.) and the slugs of the OWCategory terms that represent those OWCountry posts always identical?

If so, then I can help you create a View of OWTours with an OWCategory filter. That one View of OWTours will be placed in a Content Template that is used to display all the OWCountry posts, and it will be dynamic so we can pass in a variable OWCategory term slug for the filter. On each OWCountry post page, the same View will receive a different filter criteria based on the current OWCountry slug. Make sense?

#720953

I can create a login to help you check

#721006

Feel free to create a login and I can show you how to find the slugs, but comparing all your term slugs and post slugs isn't something I will do for you.You can find post slugs in the post editor screen, and you can find term slugs in the term editor screen. If you're not sure and you don't want to check, then that's fine but the solution is not as straightforward and will require manual modifications to each Country post. It's up to you.

#721356

Maybe you have a reference website to show this option?

#721360

Are you signed up at discover-wp.com? We have a sandbox area where you can create test sites. I can create a test site with s similar setup and invite you as an admin if you tell me your username.

#725281

Christian

Good idea, account details from discover email below.

Dear boakes,

Your new account in discover-wp is ready.
To log-in, go to:
hidden link

Login name: boakes

#728347

Invitation sent. I set up the following:
- Post Type "Countries"
- Post Type "Tours"
- Taxonomy "TourCategories", assigned to the post type "Tours"
- View of Tours filtered by TourCategories slug, set by a shortcode attribute: hidden link
- Content Template for Countries: hidden link

Then I created Countries like Kenya, Ethiopia, Botswana, etc., and made identical terms in the TourCategories taxonomy. You can see that the slugs are identical, so the TourCategories slug filter will work for our View.

Next I added the View shortcode to the Content Template and passed the current page slug into the filter:

[wpv-view name="tours-related-to-the-current-country" wpvtourcategory="[wpv-post-slug id='$current_page']"]

Now when you visit the Country posts, you can see a list of Tours associated with each Country:
hidden link
hidden link
hidden link
hidden link
hidden link

You can see that the same Tour shows up in Ethiopia and Kenya because I added both of those Taxonomy terms to the same Tour post:
hidden link

#729006

Says I have no rights???

#729097

Did you receive the invitation by email? You must confirm the invitation before you can log in. I sent the invitation to the address on your toolset.com account, s***s@b***t.com Please let me know if I should send to another address.

#729388

Just seeing this

You attempted to access the "Brochure site – My Company" dashboard, but you do not currently have privileges on this site. If you believe you should be able to access the "Brochure site – My Company" dashboard, please contact your network administrator.

If you reached this screen by accident and meant to visit one of your own sites, here are some shortcuts to help you find your way.

Your Sites
discover-wp Visit Dashboard | View Site
Listing site – Travel Destinations Visit Dashboard | View Site

#729390

My email is ******, please resend, who will it be from?

Thanks

#729431

Also so you can check the current setup to check this is possible on the website, what is your email to setup a user account please?

I do not want you to do anything other than to check this is possible with the current import from Joomla or what needs to be altered otherwise, please