Skip Navigation

[Resolved] Display only child or parent of a taxonomy

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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 14 replies, has 2 voices.

Last updated by JorgeE7101 4 years, 4 months ago.

Assisted by: Shane.

Author
Posts
#1734735

Hello,

I'm trying to find a way to display only the parent or a child of a custom taxonomy. But I can't make it work properly.

I have this taxonomy organised by: Continent — country — city.

By using this code:

[wpv-post-taxonomy type="MY TAXONOMY" format="name" id="$parent"]

I was expecting to see only the parent term displayed, but it displays all the terms separated by comma. How can I display only the Country term or the City term, not all of them?

Also is there a way to display ONLY one category term if a post has been selected with more than one category?

Many thanks.

#1734925

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Screenshot 2020-08-11 at 10.39.47 AM.png
Screenshot 2020-08-11 at 10.36.18 AM.png

Hi Jorge,

Thank you for getting in touch.

In order to achieve this you will need to create a taxonomy view to display the terms for your post. Once you've created the taxonomy view by going to Toolset -> Views you will need to match the settings like I have them in my screenshot.

This will allow you to display the terms that are parents when you add the view to a page. Ofcourse you will need to populate the with the correct shortcodes using the loop wizard in order for the items to display.

To display the children only you will need to create a child view and add it to the parent taxonomy view within the wpv-loop tags. You child view will have the settings of my first screenshot.

So for the child view you will only need the taxonomy parent filter as the child terms that will be displayed will be based on what the parent is displaying.

Please let me know if this helps.
Thanks,
Shane

#1736233

Hi Shane,

Thanks for your help. I've created a View to display one category and that is solved.

Regarding the Taxonomy view it's not working properly. So, I've created the Parent View as instructed, created the Child View and add it to the Parent View loop.

However, if I set no limits, it displays all the children of the Taxonomy. If I set it to 1, it displays the first one (in alphabetical order), but not the relevant one to the post.

Example: I have a post about London, which has been selected for the Taxonomy with the Parent Taxonomy term (Europe) and the child taxonomy term (England). However the view outputs "Germany", even though the post is not tagged with this term.

The Taxonomy is display hierarchically. Basically, if a post is tagged with Europe — England — London, I want to display on the last two (England and London).

Any clues?

Thanks.

#1737597

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Jorge,

I forgot to mention that you need to add a taxonomy Term filter to the child view as well and set it to "set by the page where the view is inserted "

This should shorten the list to only the terms that are relevant to the current page.

Thanks,
Shane

#1740265
taxonomy-child-view.png
taxonomy-parent-view.png

Hi Shane,

Thanks for that. So, I've tried it, but it doesn't work again.

I either get just one of the term "England" or I get two terms "Europe" and "London". I've tried several combinations of the settings and none displays just "England" and "London", which what I want to do.

I've attached two screenshots with the settings I have this moment.

Thanks.

#1742479

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Jorge,

Would you mind allowing me to have admin access to the website so that I can have a more detailed look at this for you?

The private fields will be enabled for your next response. Also please let me know the page that you are testing this out on.

Thanks,
Shane

#1748761

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Jorge,

Before we can proceed fully here, I will need for you to update your Toolset plugins to their latest version.

Right now you are running version 2.5.2 of Views when we now have version 3.2.2 available which has quite few improvements.

So I would suggest updating to the latest versions of the plugins and then we can take it from there in resolving this issue.

Thanks,
Shane

#1748791

Hi Shane,

I've updated now. For some reason, I wasn't receiving the Toolset updates notifications, despite having a valid subscription.

It's Views is now updated to version 3.2.2, but it has completed ruined the site. It seems that there is some incompatibility with SG Optimizer. Apparently it breaks the site if the following option is enabled:

"Combine JavaScript Files - Combine your JavaScript files in order to reduce the number of requests to the server."

This wasn't happening with the previous version of the Views.

#1748851

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Jorge,

I managed to fix the issue now, here is a test page where i've added the view just to ensure that the results are now correct.
hidden link

Secondly I would recommend that you leave this option disabled as I know that some JS optimising plugins can cause issues like this, not just with our plugin but with other plugins as well.

Thanks,
Shane

#1748887

HI Shane,

I don't understand. The view is showing exactly what I had before. It is showing all the items. In the example: Africa, Botswana.

What I need is to ONLY show the last child. In the example: to show only Botswana.

#1748909

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Jorge,

It should now be displaying the Last item, given that we have sorted it by the Title, i've limited the view to only display 1 child.

Have a look now and let me know if it is ok.

Thanks,
Shane

#1748941

Hi Shane,

Thanks for that. We're almost there. I don't want to display the parent, just the child. Is that possible?

Many thanks.

#1748953

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Jorge,

Yes this is possible, if you check the parent view, just remove the [wpv-taxonomy-title] shortcode and you should only have the child terms displaying.

Thanks,
Shane

#1748961

Hi Shane,

Many thanks. That is now working perfectly!

#1748963

All done now. Thank you