Skip Navigation

[Resolved] Taxonomy hierarchy stopped working

This support ticket is created 5 years, 10 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 – 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: Asia/Hong_Kong (GMT+08:00)

Tagged: 

This topic contains 10 replies, has 2 voices.

Last updated by Luo Yang 5 years, 10 months ago.

Assisted by: Luo Yang.

Author
Posts
#884552
new-posts.png
old-posts.png

Hello.

I've got this code in my functions.php child theme

// taxonomy order by hierarchy

function list_hierarchical_terms($atts) {
    global $post;
     
     
    $taxonomy = $atts['taxonomy']; // change this to your 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');

And I have this in the WordPress template I'm using

<h3 class="post-button-title">[display_post_tax_terms_hierarchical taxonomy="viagens" separator=" | "]</h3>

Everything has been working fine until now and is still working for old posts but for news posts, instead of getting the taxonomy terms I'm now getting "no category".

Any reason why this is happening?

Thanks.

#886582
taxonomy-view.JPG

Hello,

This is a custom codes problem, according to our support policy, we don't provide custom codes support:
https://toolset.com/toolset-support-policy/

I suggest you debug the codes manually line by line, for example:
Make sure you are using the correct taxonomy slug "viagens" in the shortcode [display_post_tax_terms_hierarchical]
If you still need to debug the custom codes, please provide a live website with same problem in below private message box.

And you can also create a taxonomy view to replace the custom shortcode, for example:
Create a view list terms of taxonomy "viagens", filter by:
Taxonomy is set by the current post
see screenshot taxonomy-view.JPG

And display the term link with shortcode [wpv-taxonomy-link]
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-taxonomy-link

#891852

It seems this is only affecting the preview, but when published it works. Any idea why?

Thanks.

#891889

Since it is a custom PHP codes problem, please provide a test site with the same problem, and fill below private detail box with login details and FTP access, also point out the problem page URL, and where I can edit you PHP codes, I need a live website to test and debug, thanks

#892133

As you mentioned above, it works fine in your test site, so It seems to be a server problem, and the credentials you provided is not valid, I get this error:

Please check it, make sure it is valid admin account.

And there is any ETA to fix such kind of problem.

#892137

Hi,

I've just checked and you can access it now. Please remove the following sentence from the public message as it contains the username to access the site...

ERRO: A senha que inseriu para o nome de utilizador **** está incorrecta

Thanks.

#894991

I have tried the credentials again, but get this error:
hidden link*****.com redirected you too many times.

And the FTP access is not valid too, I get this error:
Error: Connection timed out after 20 seconds of inactivity
Error: Could not connect to server

Please check it, make sure they are valid. thanks

#897126

Hi,

Sorry there was a issue with the server last night.

I've now checked the details and corrected the access, so it should be fine.

Thanks.

#900062

Thanks for the details, the problem is the PHP codes you are using, this line:

return wp_list_categories( 'title_li=&taxonomy=' . $taxonomy . '&include=' . $terms."&hierarchical=1"."&separator=".$separator."&echo=0&style=none");

You are using parameter "include" in your codes, and there isn't such a parameter according to WordPress document:
https://developer.wordpress.org/reference/functions/wp_list_categories/#parameters

And in your case, you can use Views shortcode [wpv-post-taxonomy] to replace your custom shortcode, for example:
[wpv-post-taxonomy type="viagens" separator=" | "]

More help:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-taxonomy

#900692

Hi.

That PHP code was supplied by Toolset...

https://toolset.com/forums/topic/maintain-the-taxonomy-hierarchy-in-a-wpv-post-taxonomy-typesport/

And if you search the support I'm far from being the only one using this code provided by Toolset.

And If I use the short code you suggested the taxonomy isn't displayed hierarchically...

Thanks.

#900875

OK, I have checked the wordpress source code, the function wp_list_categories() you are using, it is also using wordpress class WP_Term_Query to query the database, so it does support parameter "include":
https://developer.wordpress.org/reference/classes/wp_term_query/__construct/

'include'
(array|string) Array or comma/space-separated string of term ids to include. Default empty array.

And I have tested your codes in my localhost, it works fine, I can see both the parent term and child term in the result.

And the FTP access you provided is not valid, I get this error:
User ***** OK. Password required
Command: PASS ************
Response: 530 Login authentication failed

so I can not do any debug in your website, please check it, you can update your own private mesage here:
https://toolset.com/forums/topic/taxonomy-hierarchy-stopped-working/#post-891970

The problem only existed in your website, so it should be a compatibility/cache/server problem, please try these:
1) deactivate other plugins and switch to wordpress default theme, and test again
2) If the problem still persists, please backup your website, I will need to do the debug in it.

And there isn't any ETA to fix such kind of problem, hope you can understand.

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