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.
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
It seems this is only affecting the preview, but when published it works. Any idea why?
Thanks.
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
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.
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.
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
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.
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
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.
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.