Skip Navigation

[Resolved] Taxonomy Hierachy

This support ticket is created 5 years, 7 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
- 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 6 replies, has 2 voices.

Last updated by benjaminW-2 5 years, 7 months ago.

Assisted by: Minesh.

Author
Posts
#1258161

I am trying to: Display post taxonomy by hierachy

Link to a page where the issue can be seen:

I expected to see: Parent Category / Child Category1 / Grandchild Category

Instead, I got: Ordered Alphabetically

#1258205

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Well - as I understand, you want to display current post taxonomy terms in hierarchical order.

To achieve this, you need to add the following code to your current theme's functions.php file
OR
You can add the following code to "custom code" section offered by Toolset.
=> https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/

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');

You can call the shortcode as:

[display_post_tax_terms_hierarchical taxonomy="category" separator=" - "]

Where:
- Change category with your desired taxonomy slug as well as seperator value.

#1258367

Hi Minesh, thanks for your reply.
However, this doesn't seem to be working for me I'm afraid. I'm now simply getting a blank space where the categories should be. I've uploaded screenshots here...

This is from a custom post created with toolset, showing in a category archive loop.

*i'm also using the AVADA theme. The content created in the archive loops however is styled using the toolset loop output, and custom css.

Thanks for your help,
Ben

#1258389

Minesh
Supporter

Languages: English (English )

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

Can you please share problem URL and access details.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#1259329

Minesh
Supporter

Languages: English (English )

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

Well - the wp-admin access details you shared is not working at this end.

Can you please send me working wp-admin access details.

I have set the next reply to private which means only you and I have access to it.

#1259855

Minesh
Supporter

Languages: English (English )

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

Well - I've added the shortcode as given under to the following page:
=> hidden link

[display_post_tax_terms_hierarchical taxonomy="listing-category" separator=" / "]

I can see it just working fine:
=> hidden link

You can remove the existing shortcode as well as I have removed the pics from the public post as per your request.

#1259927

Thanks Minesh! My issue is resolved now. Thank you!