Skip Navigation

[Resolved] Taxonomy direct Links in mixed taxonomies

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

Problem: I have a View of taxonomy terms that I am using to create a list of links to different pages that each contain a filtered View. The links work well now, but some of the Views on these pages have no results. If the View contains no results, I would like to hide the link to that page.

Solution: Use a View as a conditional to determine whether or not results are found. If results are found, display the link. If no results are found, display nothing. Use shortcode attributes and the wpv-attribute shortcode as needed to pass information around between Views and their parent context.

Relevant Documentation:
https://toolset.com/documentation/user-guides/views/passing-arguments-to-views/
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-attribute
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-taxonomy-slug
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-taxonomy-title

This support ticket is created 4 years, 4 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)

Tagged: 

This topic contains 15 replies, has 2 voices.

Last updated by Alessandro 4 years, 4 months ago.

Assisted by: Christian Cox.

Author
Posts
#1737469

Hi, i would create a menu in toolset where user can clic like a text link.

I'll explain better.

I have mixed taxonomy urls like

1° Taxonomy -> eventi
2° Taxonomy -> citta

I combined this urls like this:
hidden link

In the menu i succeeded to show certain link creating a views that shows terms like in the Eventi Menu

Eventi
- Eventi Aziendali
- Feste Private
- Cena Aziendali

Each link links to the desired url and it works:

E.G.
Eventi aziendali links to hidden link
Feste private links to hidden link
Cene aziendali links to hidden link

It works, but i can't hide links that doesn't exits, i need to show, in the menu, just the link that exist
E.g.
If there is no posts in Feste Private & Citta=roma it shouldn't show anything

#1737871
Screen Shot 2020-08-13 at 3.37.13 PM.png

Hello, the best way to do this without custom code is to use a View that acts like a conditional. It looks like you are creating the list of links now using a View of Eventi terms, is that correct? If so, you should keep displaying this View of Eventi terms, but instead of displaying the link in the loop of this View, you will display a nested View of posts. You should display the same post type that is currently displayed at the /eventi/eventi-aziendali URL. That View of posts should have two Query Filters: one for the Eventi taxonomy, and another for the Citta taxonomy. Both Query Filters should filter by taxonomy term slug, set by a shortcode attribute like wpveventi or wpvcitta. See the screenshot here for an example.

When you insert the posts View shortcode in your View of Eventi terms, you will add the current taxonomy term slug shortcode to the wpveventi attribute, like this:

[wpv-view name="Your Posts View" wpveventi="[wpv-taxonomy-slug]" wpvcitta="roma"]

I have added "roma" as the Citta term here, as well, to make the link dynamic. Add this View shortcode inside the loop of your current View of Eventi terms.

Instead of displaying posts in the loop of the posts View, remove all the contents from the wpv-loop tags. The loop should be EMPTY. Instead, somewhere inside the wpv-items-found section, display the /eventi/eventi-aziendali/?citta=roma link using the wpv-attribute shortcode to build the link URL dynamically with the current term slug:

<a href="<em><u>hidden link</u></em> name='wpveventi']/?citta=[wpv-attribute name='wpvcitta']"><em><u>hidden link</u></em> name='wpveventi']/?citta=[wpv-attribute name='wpvcitta']</a>

Remove the "No results found" message from the wpv-no-items-found section so it is empty. If no results are found, nothing should be displayed.

Let me know if you have questions about this and I'll give you some additional guidance.

#1737931

Hi Christian, thank you.
i would try to do it.

To recap i should have 2 views:

1. Similar the one I made
2. Another one which is nested to the 1

I only can't understand where i have to put the

[wpv-view name="tipologia-eventi-menu-nested-posts" wpveventi="[wpv-taxonomy-slug]" wpvcitta="roma"]
#1737955

Yes, your recap is correct. You should have two Views:
View #1 - similar to the one you already made. Let us assume this new View has the slug "new-eventi-terms-view".
View #2 - a new View of posts. Let us assume this View has the slug "tipologia-eventi-menu-nested-posts".

You should place View #2 inside the wpv-loop tags of View #1. Then you should place View #1 on the site where you want to display the list of links.

#1737959
Schermata 2020-08-13 alle 22.40.20.png
Schermata 2020-08-13 alle 22.40.35.png
Schermata 2020-08-13 alle 22.40.54.png

Sorry
I'm very confused 😀

#1737985

It looks like something got corrupted in the new-eventi-term-view code when you copy + pasted the link code. Would you like to provide a login so I can help set this up? Let me know where you would like to display the list of links on the front-end of your site.

#1738003

Okay I have the Views set up now. You can check the results here:
Eventi Aziendali: hidden link (both links appear)
Feste Private: hidden link (both links appear)
Eventi Aziendali: hidden link (only eventi-aziendali link appears)
Feste Private: hidden link (only eventi-aziendali link appears)
Eventi Aziendali: hidden link (both links appear)
Feste Private: hidden link (both links appear)

Look at the new-eventi-term-view here:
hidden link
You can see I am using the citta URL parameter (wpv-search-term gets the current URL parameter) to set the Citta Query Filter term slug:

[wpv-view name="tipologia-eventi-menu-nested-posts" wpveventi="[wpv-taxonomy-slug]" wpvcitta="[wpv-search-term param='citta']"]

This will only work in URLs with citta as a URL parameter like this:
hidden link
It will not work like this:
hidden link

If you want to support both URL formats, something needs to change, but I don't understand your site well so I'm not sure how that would work. We need a shortcode that represents "roma". In the Elementor template, you would replace the View widget with a text widget and place the View with a shortcode like this:

[wpv-view name="new-eventi-term-view" citta="[SOMETHING?]"]

Then in the new-eventi-term-view, you would change it to be:

[wpv-view name="tipologia-eventi-menu-nested-posts" wpveventi="[wpv-taxonomy-slug]" wpvcitta="[wpv-attribute name='citta']"]

But I don't know what SOMETHING? should be here. Do you understand what I mean?

#1738007

Wow! It works
The website can take city taxonomy from the shortcode [citta-location-slug] now i'll try to implement it

#1738009
Schermata 2020-08-13 alle 23.45.14.png

Sorry i have a problem while inserting the shortcode in elementor it appears a "]

#1738059

What type of block are you using? Elementor's "shortcode" block does not support nested shortcodes, so you should use a Text block instead. If you have trouble, please copy + paste the full shortcode here and I will take a look.

#1738071

I used any types of block.
I also added [citta-location-slug] Manual Shortcode in toolset setting

If you need you can always enter in the admin to check

#1738073

Ok i modified the view to use the view block. Now it seems to work

#1738075

Yes it works, can you help to create a link badge to remove filters, or i need to create another ticket?

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

https://toolset.com/forums/topic/create-link-badge-to-remove-filters/

#1741655
Schermata 2020-08-17 alle 10.41.10.png
Schermata 2020-08-17 alle 10.40.28.png

While visiting hidden link it has a 404

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

https://toolset.com/forums/topic/404-error-for-custom-post-type-location/

#1742113

Yes it works, can you help to create a link badge to remove filters, or i need to create another ticket?
I can help, but a separate ticket would be best since this is a different topic. I'll split this and your question about Location posts 404 errors into separate tickets so we can discuss in more detail.