Skip Navigation

[Resolved] view in view with 2 taxonomy

This support ticket is created 6 years, 5 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 12 replies, has 2 voices.

Last updated by fabienG-2 6 years, 4 months ago.

Assisted by: Waqar.

Author
Posts
#1116475
Capture.JPG

Hi,

I have a custom post type "lieux" with 2 custom taxonomy ("pays" and "style de voyage")
I would like to display all "style de voyage" with the term "Safaris"and group by the name of the "pays" taxonomy.
I try with this how to https://toolset.com/2015/07/how-to-group-posts-by-category/ but I did not succeed
thanks a lot

#1117174

Hi Fabien,

Thank you for contacting us and I'll be happy to assist.

To achieve what you’re planning, you’ll create two views, similar to the guide ( https://toolset.com/2015/07/how-to-group-posts-by-category/ ), but with a few exceptions:

1. The Parent view will be a taxonomy view to show a list of all the “Pays” taxonomy items.
(No query filtering will be needed in this case)

2. A child view will then be needed to show all “lieux” custom posts, which are:

a). attached to the term “Safari” from the “style de voyage” taxonomy
AND
b). are also attached to the ”Pays” taxonomy term which is “Set by the parent taxonomy” view.

Here is how the Query Filter settings for this View will show:
Screenshot: hidden link

You can then nest this child view, into the “Loop Editor” of the parent view. e.g.


<wpv-loop>
   <li>
              [wpv-post-body view_template="Loop item in View to show all countries"]
              [wpv-view name="view-to-show-places-linked-to-safari"]
   </li>
  </wpv-loop>

I hope this helps! Please let us know how it goes and if you need any further assistance.

#1117194

Thanks a lot!
The result is here : hidden link
a have few more question please:
- how to not display empty result like

Afrique
No items found child

- disable the display of parent of "pays"
Asie Océanie
ALTAÏ RUSSE
ALTAÏ CHINOIS
Vallée de l’Orkhon
Karakorum
Oulan Bator

In this case It's need to only display
Chine
ALTAÏ CHINOIS

Mongolie
Vallée de l’Orkhon
Karakorum
Oulan Bator

Russie
ALTAÏ RUSSE

Thank you very much

#1118187

Hi Fabien,

Thanks for the update and glad my suggestions helped.

To hide the parent countries, which don’t have any results, you can add the following script at the “JS editor” tab, just under the “Loop Editor” (in parent view):


$(document).ready(function () {
   $(".entry-content strong:contains('No items found child')").parent('div').hide();
   $(".entry-content strong:contains('No items found child')").parent('div').prev('h1').hide();
});

For a more customized solution with custom jQuery script, I’ll recommend consulting jQuery forums or consider contacting one of our certified partners from this link:
hidden link

If we can be of any further assistance, please let us know.

Regards,
Waqar

#1119148

Hi Waqar,

I advance well on the project, thanks!
Now how I can filter the display by category or other taxonomy (not created yet).
This category or taxonomy will be "Continent".
So after that the listing can be reduce by "asia", "africa" etc... after have clicked on asia for example

thanks!

#1120412

Hi Fabien,

Thanks for the update and glad you're making progress with the project.

To include another filter "Continent", you can register its taxonomy parallel to the two existing ones ( "pays" & "style de voyage" ).

After that, you can include another query filter to your child view ( that shows the “lieux” custom posts ) that "Continents slug in one of those set by the URL parameter wpv-continent".
( screenshot: hidden link )

This will allow you to further filter the page, based on the slug of the continent, passed in the URL parameter:
e.g. hidden link

Tip: To show the list of the links for the available continents, you can create another view that lists all the continents, with a link in the format shared above.

I hope this clarifies and please let us know if you have further questions

#1120595
Capture.JPG

Hi Waqar,

thanks, I created Continents slug in one of those set by the URL parameter continent, in child view.

But I'm blocked here : "Tip: To show the list of the links for the available continents, you can create another view that lists all the continents, with a link in the format shared above."
It's another view than the parent view?
I would like to appears a filter in the parent view to display the list of continent and refresh the result in ajax.
I have the message in attachment, if I want to set a filter.

thanks a lot

#1121558

Hi Fabien,

Thank you for sharing the screenshot and your observation is correct.

Since the parent view is listing a taxonomy and not a post type, the custom filtering options can't be used with it.

As a workaround, It is possible to add links to all the available continents on top of the page, which will act as a filter that limits the results, only to that continent (but it will reload the page and won't be AJAX based).

For this you can follow these steps:

1. Please create a new taxonomy view that lists all the continents.

2. In the "Loop Editor" you can set it to show results in an unordered list and in the template you can include the link, in this format:


<a href="LINKTOPAGE/?wpv-continent=[wpv-taxonomy-slug]">[wpv-taxonomy-title]</a>

Note: please replace "LINKTOPAGE" with the actual link to the page where the parent view to show a list “Pays” is added.
Also, make sure to update the parameter "wpv-continent", to match what's set in your child view's query filter.

3. Next, you can show this new view on top of that existing parent view by adding it on that same page, before the existing view.

As a result, you'll have a list of all the continents on the top and clicking each one, will refresh the page and only results from that continent will show.

Let me know how it goes and if you need any further assistance.

#1121590

Hi Thanks Waquar

I set hidden link;">[wpv-taxonomy-title]

code :

[wpv-layout-start]
[wpv-items-found]
<!-- wpv-loop-start -->
hidden link;">[wpv-taxonomy-title]
<wpv-loop>
[wpv-post-body view_template="Loop item in ok Parent view"]
[wpv-view name="ok-child-view"]
</wpv-loop>
<!-- wpv-loop-end -->
[/wpv-items-found]
[wpv-no-items-found]
[wpml-string context="wpv-views"]No items found[/wpml-string]
[/wpv-no-items-found]
[wpv-layout-end]

But it display a country not a continent hidden link
It seem to display the wrong taxonomy.
And also my link have another parameter les_styles_de_voyages as you can see in my link, after click on the list I will loose this parameter.

thanks

#1122711

Hi Fabien,

Thanks for writing back.

From your message, it seems that you've added the custom link (suggested in step 2) directly in your parent view, that was originally created to show a list of countries.

As suggested in step 1, you'll first create a new child view that will show the list of continents. The custom link suggested in step 2 will need to be added to that new view's content template.

Following screenshots show how the new taxonomy view for continent was created on my test website and how it was included on top of the parent view:

screenshot 1: hidden link
screenshot 2: hidden link

To avoid losing the other parameter "les_styles_de_voyages" from the URL, you can create a custom shortcode that gets the current page link and all query parameters and preserves them to create a new link which also includes "continent" parameter.

The use of "les_styles_de_voyages" parameter indicates that you'd like your view to also adjust the filter for "style de voyage", taxonomy terms (and not just limit it to "Safaris").

To have a view that filters the post type "lieux", based on multiple filters on the fly, you can also alternatively consider creating a new "search page with filters" view that shows the custom post type "lieux" and includes multiple filters for country, continents and travel style taxonomies, which can be simpler to manage.

Following are some useful guides on the topic:
https://toolset.com/documentation/user-guides/front-page-filters/
https://toolset.com/documentation/user-guides/filtering-views-by-taxonomy/

If we can be of any further assistance, please let us know.

Regards,
Waqar

#1123885

Hi Waqar,

thanks a lot I work on this!

Regards
Fabien

#1124542

You're very welcome, Fabien.

Please let me know if I can be of any further assistance.

Have a great day!

#1124592

My issue is resolved now. Thank you!