Get category ID after wp_insert_term
It should be a key of term_id, so echo out $cat_id[‘term_id’] and you should get the new terms ID.
It should be a key of term_id, so echo out $cat_id[‘term_id’] and you should get the new terms ID.
We had the same issue in one of our projects and we find the solution here This other doesn’t work in our case, but maybe is a second option for you.
Use wp_is_post_revision() function which will give you false if post is not a revision (in which case just work as usual with that) or actual post ID to use instead of revision’s.
You need to set the database collation to utf8_polish_ci in your wp-config.php to get correct sorting.
Thanks to this answer, I was able to see the light. Here is how to query taxonomy terms related to (woocommerce) products that are “in stock”. It uses both tax_query (to relate product to taxonomy) and meta_query (to filter out out-of-stock products). $artists = get_terms_by_post_type( array(‘artist’), array(‘product’)); if( !empty($artists) && !is_wp_error( $artists ) ){ // … Read more
In your get_terms() call, try setting the hierarchical option to false: $children_terms = get_terms($taxonomy, array( ‘parent’ => get_term_by(‘slug’, $parent_term, $taxonomy)->term_id, ‘hierarchical’ => false )); This option normally defaults to true, which is probably why you’re getting the extra copies.
I was pretty sure of this, but the answer is—at least for now—a definitive no. There isn’t an API call for it. To double-check, I asked core developer Andrew Nacin about this on Twitter. His response: term_taxonomy_id is, for the moment, essentially private. You should likely never have it to use it. It might be … Read more
We can filter the generated SQL query through the terms_clauses filter before the SQL query is executed. What we will be doing is to introduce a new parameter called wpse_parents which will accept an array of parent term ID’s to get children from. Note, this new parameter works exactly the same as the build-in parameter, … Read more
The wp_list_categories() function calls the get_categories() function, that’s a wrapper for the get_terms() function, that creates an instance of the WP_Term_Query class. It doesn’t look like it supports ordering by term order. If the plugin uses the term_order column in the wp_terms table, then you can try to add a support for it’s ordering, via … Read more
You can get terms, from multiple slugs, with the slug argument: $exclude = get_terms ( [ ‘slug’ => [ ‘president’, ‘vice-president’, ‘admin’, ‘rnd’ ], ‘taxonomy’ => $cat_type, ‘fields’ => ‘ids’, ] ); where we use the fields argument to return only term ids.