post_type_link not working for posts without terms
post_type_link not working for posts without terms
post_type_link not working for posts without terms
Make sure that you have the correct slug for the taxonomy or tag.
It sounds like you’re looking for get_ancestors(). In your case, something like get_ancestors( $term_id, ‘product_cat’, ‘taxonomy’ ); should get an array of ancestor (parent, grandparent, etc) IDs for a given $term_id.
Add text in custom taxonomy
Foreach for get_the_terms for hierarchical taxonomy don’t repeat Top Level Terms if contains multiple Second Level Terms
With: wp_add_object_terms( $cpt_dates_post_ID, intval($manifestation_insert_id), ‘cpt_dates_postID’); You’re actually saying “Add a cpt_dates_postID term with ID intval($manifestation_insert_id) to the CPT with ID $cpt_dates_post_ID“. That won’t work, because intval($manifestation_insert_id) is the ID of: another post (from another CPT, freshly inserted with […] Not the ID of an existing $cpt_dates_post_ID term entry. The reason why these 2 work: wp_add_object_terms( … Read more
You’re correct that the issue is caused by the fact that the rewrite rule is set to include the %tax-name% placeholder even when a taxonomy is not set for the post. One way to dynamically set the rewrite rule based on whether a taxonomy is set or not is to use the post_type_link filter. This … Read more
pre_get_posts is an action hook used for modifying the arguments passed to the WP_Query class, and if you’re filtering the posts in the list table at wp-admin/edit.php, then yes, you would use that hook. However, since you’re filtering the terms in the list table at wp-admin/edit-tags.php, then the hook that you should have used is … Read more
That’s because some terms are reserved by WordPress core and shouldn’t be used as custom slug. However, WordPress core itself doesn’t check within register_taxonomy function whether a developer has used those reserved terms or not. It’s up to the developers to read the documentation and implement accordingly. These core functions are low level implementations, so … Read more
How to delete unused terms?