Skip Navigation

[Resolved] Displaying Hierarchical Taxonomy Child Categories in Blocks

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

Problem:
The user would like to display child terms in a term archive page with blocks as a slider.

Solution:
Currently, with blocks, creating taxonomy views is not yet available. We will need to create a taxonomy view, to view the term children with legacy views, and use it inside a view block. The view needs to be filtered for children of the term of the current archive page.

To enable to legacy views editor, go to WPML->Settings->General->Editing experience

We cannot have this view as a slider because of a known issue on Archive templates. We cannot have AJAX enabled for another template except the archive loop. Sliders are based on AJAX

Relevant Documentation:

This support ticket is created 4 years 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: Africa/Casablanca (GMT+00:00)

This topic contains 18 replies, has 2 voices.

Last updated by DaveR6137 3 years, 12 months ago.

Assisted by: Jamal.

Author
Posts
#1573515

Hi There,

I'm not sure if this is something i'm doing wrong, or if there are issues with doing this via Blocks, so any help appreciated.

I'm trying to create an archive template for a new taxonomy which i'm intending to provide a richer content than standard archive pages. I've achieved something similar with Toolset on another site by using custom posts - hidden link - which works on a combination of categories and related posts - but i'm not to keen as the 'bases' posts are mirrored by categories and isn't elegant. It's also not practical for hidden link as I have 1000 custom posts that would each require some modification.

So i'm trying to do this by using the Blocks Editor - which I've decided i need to start using - but other layouts on my site are still using Layouts.

I created a view - Content Selection = Taxonomy and Query Filter = Taxonomy parent filter -
Select taxonomy terms whose parent is the current taxonomy archive. I was unable to embed this in the Blocks - as the Insert Taxonomy option is Blue, so i created a nested view.

This results in the child taxonomies appearing on the page - but there are multiples - all the taxonomies I've created are there 3 times each.. I've tried what feels like every permutation - no luck.

HOWEVER if i paste the initial view into my category text - this then renders only the 2 child categories.

Can you confirm that this is a limitation in using Taxonomy Views in Blocks or if I need to be doing something differently.

The page is -hidden link

There's a Walks-in-the-mourne-mountains-aonb as main category, and 2 child taxonomies - Mourne 1 and 2. You can see these on top of the page above - this is the shortcode pasted directly into the taxonomy description.

At the bottom of this page is the nested view that i embedded in Blocks - which just gives a totally different result. Unfortunately - this doesn't seem to be working when i embed it in the Blocks. There's a title there explaining that - but no result below..

I've tried Blocks as i'm having difficulty with the formatting in Layouts when it comes to archives (and minor issues elsewhere - see my other open ticket). I also wish to transfer all my workflow over to blocks in time - so this is the workflow that I think is the right one to follow as that's the way Toolset is moving.

Hopefully that all makes sense. I'll supply more info, screenshots, and so on - once you confirm that what i'm doing is doable - or that it's not yet implemented in Blocks.

Thanks for your patience!

#1574141

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Hello and thank you for contacting the Toolset support.

I am sorry but I did not understand where did you insert your view using blocks, can you give detailed steps to follow to reproduce the issue?

Toolset Blocks still has some limitations compared to Views, such as taxonomy or user Views, or nested Views, but these are all in the pipeline. For these limitations, we create legacy views then we use them in Gutenberg:
- Use as a View block.
- Inside a classic block using a shortcode or the "Fields & Views" button.
- Inside a "Fields and Text" block.

Let me know more details about your use case and I'll try my best to help.

#1576133

Hi Jamal,

Thanks for getting back to me.

What I'm trying to do, is create a legacy View which i'm then trying to display either as a nested View or as a shortcode within Blocks.

I can get the view working perfectly as a shortcode inserted in the Taxonomy Description (which can be sen on the top of the page linked below). It's returning the two sub-taxonomies as it should. Obviously i need to format these better into bootstrap columns:
hidden link

But I cannot get this same view to work by creating a nested view or by embedding as a short code. The nested view brings back duplicate results.

I've also tried embedding as a shortcode - and this brings up the same result.

So yes - i think I've tried to use the view in all of the three ways you mention - and they don't seem to be working.

Happy to provide access if you want to take a closer look..

Oh yes, I also tried creating an archive totally via layouts, but I'm having some issues getting them to format properly (either a bug or another plugin incompatibility) so would rather try via Blocks for that reason as well as the Blocks providing the basic archive out of the box (whereas i need to recreate everything in Layouts - though that could be my mistake)

Cheers,

Dave.

#1577163

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Hi Dave and thank you for your feedback.

I would encourage you to use blocks as much as possible. Layouts plugin is now only on a maintenance mode and will not get any additional reasons as we are moving into blocks only experience and integration with popular page builders.

Regarding the taxonomy page, I would like to get access to a closer look. Your next reply will be private to let you share credentials safely. Please take a database backup before sharing credentials.

#1579853

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Hello Dave and thank you for the credentials. I get accustomed a bit to your website(post types, taxonomies).
As I am not used to the reference site, I still do not understand very well what you would like to get.
hidden link

Currently, your archive page has created a content template for the loop, but then the loop was customized to use in-loop blocks, not a content template hidden link

This gives me some doubts about what you would like to achieve.
Do you want to achieve the following:
- Taxonomy term (title + description), let's call it (Term_A)
- Filter for term children of Term_A (Term_A-1 and Term_A-2)
- List of posts of Term_A, or only of child terms when filtered.
Is this what you would like to have?

#1582433

HI Jamal,

Thanks for taking a look - and i think I've confused things a little! The screenshot you've saved - the loop in this was created automatically when i went to edit the taxonomy archive.

You're right - i'm trying to show on a taxonomy page - (ideally with filter) the child taxonomies for that taxonomy along with a brief snippet. I've only done this on the other site (Mtb-rider.net) by using post types rather than taxonomies).

The taxonomy page will already show the posts that fall under the taxonomy and the child taxonomies and i don't need to show both posts and taxonomies in the same view. I'm intending to show the child taxonomies as one view and the posts beneath (which is probably where I'll add a filter).. I think I'm more concerned about being able to have the view showing what i need in the first place, I'm sure the filters will then be easy enough to add later.

If this isn't making sense - i'm happy to mock a hierarchy and the page layout as a graphic if that helps?

Cheers,
Dave.

#1582449

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Hello Dave,

Yes, please, draw a page layout to show me what you would like to have. And remember that this is an archive page, so, there must be a section on the page to show the posts under the taxonomy term.

Thank you,
Jamal

#1585635
noname.jpg

Hi Jamal,

Here's the example as I roughly expect it to be.

I can't see an issue with most of this - only with section 2.

I'm also going to have a go on another website which is running a very similar setup (same theme, toolset, etc).

Hope that helps?

Dave.

#1587221

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Hi Dave,

You have already created the 1st and 3rd sections in your current archive template. For the 2nd section, it is not yet available within blocks. We'll need to create a legacy view that displays child categories. Then we'll use it inside a view block on the archive template.
Inside this view we must not use Content Templates, otherwise, it won't work. I have tested it locally, while it works perfectly when not using pagination, it did not work correctly with a slider, and some terms that are not children were also displayed on the view.
I have the following places:

Place 1
— Place 1.E
— Place 1.D
— Place 1.C
— Place 1.A
— Place 1.B
Place 2
— Place 2.A
— Place 2.B

Check my screenshot hidden link it should not show Place 2 and children.

Check my view screenshot, it does not use content template hidden link

Let me check with our 2nd Tier about it and get back to you.

#1589771

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Hello Dave,

According to our developers, we cannot actually put an AJAX paginated view inside a taxonomy archive. The taxonomy archive is already paginated and it is very tricky to insert another pagination on the template and to serve it from the server.
Currently, we have no solution for this limitation https://toolset.com/errata/ajax-pagination-broken-on-taxonomy-view-added-to-taxonomy-archive/

But I can suggest a workaround which will need some technical skills. You can configure the view(children terms) to display all the results without pagination and customize the view HTML and Javascript to implement your own slider. You can use any slider/carousel jQuery plugin available on the internet.

I hope this helps. Let me know what you will implement.

#1590763

Thanks Jamal,

Just to clarify - the pagination on this isn't essential - I'm just trying to replicate another site which uses a custom post type to do this. Pagination like this would only serve to look 'cool' rather than affecting any functionality of the site.

Being able to show the child taxonomies on this page is sort of essential to the functionality of what I'm trying to develop - and I don't want to create new post types for this as I'm using that on another site and I'm not 100% convinced that's its the best way of doing things (I've duplicated taxonomies to reflect the custom post types - so not practical on Mud and Routes).

If i choose not to use pagination - will this still be possible to create a view? I'm considering using a diferent style for the child taxonomies - where there's just a featured image with overlaid text - which i know I can do manually - is this the kind of technical implementation you mean? That's the sort of limit of my technical skills - i can dabble in html, css and i have managed to create a formatted layout from scratch - so hopefully this is doable.

Also - will i be able to implement a filter on this view? And will a child view on taxonomies ONLY show children or will it show grandchildren as well. Regular post archives show both, on my theme at least. Ideal behaviour is to only show child items, but if i can filter then it doesn't matter.

I'm trying to visualise the possible solution and i can see a view returning say 8-10 items working, if i can filter them, depending on what child/grandchild taxonomies are shown as i don't think there are many taxonomies with more child terms than that (and i'm willing to modify my taxonomy structure to fit this if needed)

If i need to go down the line of adding a slider manually - are there any examples on the example sites on toolset or any starting point you can recommend - no problems if not as i understand that might be going beyond regular support.

Thanks again.

#1590803

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Yes, you can customize the child taxonomies' view to include an image or any term information.

This child taxonomies view will display only the children of the current archive term. Not its grandchildren. The WordPress archive instead will show all posts assigned to this taxonomy term and its children and grandchildren.

Archive pages do not allow to filter/search posts right now. You can have it on pages with views though.

Blocks currently do not allow to set a view filter on taxonomy, only on custom fields, for any view where you want to filter on taxonomy, you will have to create the view in the classic editor.

I hope this answers your question. Let me know if you have any doubts.

#1591041

Thank you Jamal,

I think that i'm now clear that I'm unable to do this via Blocks and will investigate using a combination of views and possibly editing some of my template files and layouts?

As it means i might need to revert to layouts - as I used this on another site for a CPT based archive - I may have to open a new ticket as I'm having serious issues with applying layouts to archives.. I'm going to undertake some troubleshooting first - and check for any plugin conflicts (I suspect Jetpack's Cookie Consent isn't playing nicely).

Thanks for the help.

#1593169
Snowdonia National Park Archives _ Mud and RoutesMud and Routes - Google Chrome 20_04_2020 19_33_19.png
Snowdonia National Park Archives _ Mud and RoutesMud and Routes - Google Chrome 20_04_2020 19_42_05.png

Hi Jamal,

Sorry to reopen this - but I'm having issues with getting the layouts to work with the archives and i suspect there's an issue somewhere.

I've got most of what I'm after working using layouts and views on this archive - hidden link - This is a massive step ahead and some useful functionality for the site.

But if you inspect element you'll notice that the archive items are appearing outside the main page area - this is even more obvious if you open the link on a mobile. Please see screenshot 1 for the inspect element issue - you can see the toolset element is wider than what it should be so something isn't rendering correctly in the first instance.

I've got as far as troubleshooting the issue in troubleshooting mode and the archives don't seem to render properly in my current theme or in the standard theme and in TwentyEleven. The formatting Issue appears in the vanilla theme - so I'm suspecting that this is Toolset related (it could be the formatting I've put on the archive items). screenshot 2. All i had running was the essential toolset plugins and the simple theme.

Also note that the category description should be 3 paragraphs, and they're being stripped out. While the Archive block is working OK - the filter isn't showing any sub-categories and I had hoped to have had this paginate with ajax to keep things tidy, but that just returns a blank. Also - the title above the archive (Walking Routes in Snowdonia National Park) is centred when it should be to the left (I've created countless similar layout items and this isn't the expected behaviour)

Hopefully that makes sense ?

Thanks again,

Dave.

#1594461

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Hello Dave,

I don't know what component is responsible for this, but it seems that a javascript code makes all the content of the page as a masonry grid, which adds a style "height:0px!" for a container div. Check these screenshots:
- Javascript hidden link
- Container hidden link

I believe it is an Astra theme setting. To confirm it, please switch temporarily to a different theme and check if the issue is reproduced.

We could work around it by adding a custom Javascript code to undo that. I added the following code to the view of the WordPress Archive Cell, and it seems to work.

jQuery(function($){
  $("#main > .ast-row").imagesLoaded(function(){
    setTimeout(function(){
      $("#main > .ast-row").css("height", "auto")
    }, 1000)
  })
})
This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.