Skip Navigation

[Resolved] Displaying tags parent, child, child; parent, child, child, child

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

Problem:
Displaying tags parent, child, child; parent, child, child, child

Solution:
To display the post term hierarchically you will have to write custom shortcode.

You can find the proposed solution in this case with the following reply:
https://toolset.com/forums/topic/displaying-tags-parent-child-child-parent-child-child-child/#post-2378845

Relevant Documentation:

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 8 replies, has 2 voices.

Last updated by lesleyA 1 year, 10 months ago.

Assisted by: Minesh.

Author
Posts
#2377001
Screen Shot 2022-06-03 at 10.30.07.png

Tell us what you are trying to do?
Following on from some useful help yesterday with displaying tags in a taxonomy in a bespoke order, I now realise that I need to go a step further. I need my tags to display like this:

Parent
- child
- child
Parent
- child
- child
- child

Presently, I have this:

Parent
Parent
Parent
- child
- child
- child

I did a bit of research and figure that I may need to use nested views and found documentation for legacy features which shows that it is possible to show a Taxonomy view with a taxonomy view for a child. Image attached shows roughly what I'm hoping to achieve.

However, I'm clearly getting it all wrong because I end up with long lists of "no items found"

Here's what I did:
I created the child view that will be nested using a taxonomy filter, selecting the posts with the taxonomy: [my taxonomy] set by the parent taxonomy view. Inside that view, I added a field to display the taxonomy.

Next I created a parent view using a taxonomy filter, selecting the posts with taxonomy [my taxonomy] in all of the (parent) tags (via the checkboxes).
In the view I added a field to include the shortcode for the child view that I previously created.

But I was hoping to find something whereby I could select "parent is none" for the top level.

And then I will need to do something to show only the tags relating to the current post, as I only want the relevant tags to display.

Is there any documentation that you are following?
I've been using this, but wondered if there was anything more relevant:
https://toolset.com/documentation/legacy-features/views-plugin/using-a-child-view-in-a-taxonomy-view-layout/

Is there a similar example that we can see?

What is the link to your site?

#2377061

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Have you checked the following article?
- https://toolset.com/2015/07/how-to-group-posts-by-category/

Does that help you to resolve your issue?

#2377241
Screen Shot 2022-06-03 at 16.02.05.png
Screen Shot 2022-06-03 at 15.54.49.png
Screen Shot 2022-06-03 at 15.54.14.png
Screen Shot 2022-06-03 at 15.53.08.png
Screen Shot 2022-06-03 at 15.52.48.png

Hi Minesh

It should solve my issue and it makes sense but I'm only wanting to display the term and am getting somewhat muddled.

My taxonomy is called Supplier Specialisms
Within I have tags such as
Marketing (parent)
- design
- copywriting
- web design
HR (parent)
- training and development
- wellbeing

(There are seven parents and each has a number of children.)

But I only want to display the tags that relate to the current supplier's specialisms… do I need to nest another view to get it to display the content for the post?

In the attached screen shots, the first view is the child and the second view is the parent. And, so far, I've only managed to achieve "no items found" or a long list of all the tags in the taxonomy.

Yikes! Hope you can help me!

#2378769

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Yes - you will have to use the nested view but you can use nested views in classic mode as Toolset Block does not support nested views.

Here is a sandbox site and you can login to that using the following link:
- hidden link

If you can setup a minimum structure with content for your taxonomy and tell me in what format you want to display and what I'm happy to build those view for you.

#2378807

Thank you Minesh

In the sandbox I have added a taxonomy called styles to the CPT Holiday Homes. The tags have parents and children.

I have made a template to display the Holiday Homes and there are 3 posts. I have used Fields and Text to display the relevant dynamic tags. You will see that each post has assigned different styles, some with and some without the parent tag. The tags are shown in alphabetical order, but what I require is the tags to be displayed parent, child, parent, child. For example, "Accommodation C" shows these tags:
Exterior finish (parent)
Planting (parent)
pastel (child of Exterior finish)
south-facing rear garden (child)
tile-hung (child)
white (child of Exterior finish)

But the order should be:
Exterior finish (parent)
pastel (child of the parent above)
white (child of the parent above)
Planting (a parent without any children selected)
tile-hung (a child without its parent selected)
south-facing rear garden (a child without its parent selected)

I hope that makes sense, and I know it sounds a convoluted, but this is what my client is asking for.

Kind regards

Lesley

#2378845

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I've added the following shortcode to "Custom Code" section offered by Toolset:
=> hidden link

function list_hierarchical_terms($atts) {
    global $post;
           
    $taxonomy = $atts['taxonomy']; 
    $separator = $atts['separator'];
    $terms = wp_get_object_terms( $post->ID, $taxonomy, array( "fields" => "ids" ) );
    if( $terms ) {
        $terms = trim( implode( ',', (array) $terms ), ' ,' );
        return wp_list_categories( 'title_li=&taxonomy=' . $taxonomy . '&include=' . $terms."&hierarchical=1"."&separator=".$separator."&echo=0&style=none");
          
    }
}
add_shortcode('display_post_tax_terms_hierarchical', 'list_hierarchical_terms');

I called the shortcode as given under by adding it to the "Fields and Text" block:
=> hidden link

[display_post_tax_terms_hierarchical taxonomy="style" separator="<br />"]

You can see the output on the frontend:
- hidden link

This is the possible solution you will require to use.

#2378905

Thank you Minesh

I will hopefully get to test this very soon, but for now I have a bigger problem in that I can not longer edit my templates. I'm going to raise another ticket as I think it is a separate problem.

I will return here as soon as.

Kind regards

Lesley

#2379427

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Ok fine - you are welcome to mark resolve this ticket when you can. 🙂

#2380453

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.