Custom taxonomy terms not showing as list Gutenberg Editor
Changing the slug of taxonomy works for me. Don’t know the reason behind it but it works.
Changing the slug of taxonomy works for me. Don’t know the reason behind it but it works.
Your code is correct, well almost correct. On first view, I must confess, I missed it too. You have two syntax errors in your code. If you look closely, ‘parent ‘ and ‘parent’ is not the same. You should not leave blank spaces between single quotes (‘) and arguments. Also, you don’t need to add … Read more
The hierarchy is cached and it’s not invalidated properly. This is a bug, still unresolved as of WP 3.1. A workaround would be to call delete_option(“{$taxonomy}_children”); directly. See the _get_term_hierarchy() function.
wp_get_object_terms() returns the terms associated with an object (eg a post or a page or custom post) as text (normally in an array). From the Codex page for wp_get_object_terms() $productcategories = wp_get_object_terms($post->ID, ‘productcategories’);
Thanks to Ivaylo for this code, which was based on Bainternet’s answer. The first function below, get_term_top_most_parent, accepts a term and taxonomy and returns the the term’s top-level parent (or the term itself, if it’s parentless); the second function (get_top_parents) works in the loop, and, given a taxonomy, returns an HTML list of the top-level … Read more
This isn’t possible “out of the box”… The default ‘orderby’ options are (ascending or descending) ID name Default slug count term_group These are all detailed in the codex. — That said there are some clever ladies & gents here. If anyone can solve it, one of these guys can i’m sure!
Have you tried using the WP_Query class? You might find it’s easier to use the built-in tools for this instead of a custom query from scratch. Something similar to the following should work for you: <?php $args = array( ‘post_type’ => ‘recipe_cpt’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘recipe_tx’, ‘field’ => ‘term_id’, ‘terms’ => 37 … Read more
register_taxonomy() is the tool for the job. From the Codex: This function adds or overwrites a taxonomy. One option would be to copy the register_taxonomy() $args and modify them. However, that would mean that any future changes to the original register_taxonomy() code would be overwritten. Therefore, at least in this case, it’s preferable to get … Read more
Yes, just pass in the parent parameter to get_terms when you call it, as Michael pointed out. Since WP 4.5 this is the recommend usage: $myterms = get_terms( array( ‘taxonomy’ => ‘taxonomy_name’, ‘parent’ => 0 ) ); Prior to WP 4.5 this was the default usage: $myterms = get_terms( ‘taxonomy_name_here’, array( ‘parent’ => 0 ) … Read more
In looking at the WP_Tax_Query class in /wp-includes/taxonomy.php, I found that there is a ‘include_children’ option which defaults to true. I modified my original get_posts() call with the following, and it works great: $pages = get_posts(array( ‘post_type’ => ‘page’, ‘numberposts’ => -1, ‘tax_query’ => array( array( ‘taxonomy’ => ‘taxonomy-name’, ‘field’ => ‘term_id’, ‘terms’ => 1, … Read more