wp_set_post_terms struggle :(

Just by posting.. I made a final test. And I suspected a conflict somewhere in the custom taxonomy names, what I did is I changed the name of the custom taxonomy in function.php wp_set_post_terms( $post_id, $county, ‘kommun1’); is working well 🙂 I got so focused on the variable. my bad… have a nice day

How to show term child only if has a post

AS per my knowledge you need to write following function in your functions.php and check whether the term has post using the below function function check_term_posts($tax_slug, $term_id) { $args = array( ‘post_type’ => ‘post’, ‘status’ => ‘publish’, ‘tax_query’ => array( array( ‘taxonomy’ => spanishcategory, ‘field’ => ‘term_id’, ‘terms’ => 169 ) ) ); $term_query = … Read more

Confused by get_the_terms to use in a new wp_query

$terms is an array of terms, so PHP doesn’t know what you mean when you say $terms->slug. With foreach, you’re iterating through this array. If you only care about the first element, you can simply use $slug = $terms[0]->slug;. This will get you in trouble when there are no terms, though, so you will want … Read more

How to display taxonomy order child, parent

You can add following code in functions.php file of child theme or custom plugin add_filter( “term_links-local”, ‘reverse_order’ ); function reverse_order($links) { $new = array_reverse($links); return $new; }

Order get_terms by multiple values

WP_Term_Query, which powers get_terms(), does not support ordering by multiple properties the same way WP_Query does. But, since you don’t need to worry about pagination, you’ll be able to achieve the result you want by sorting the results after querying them: $allcities = get_terms( array( ‘taxonomy’ => ‘city’, ‘hide_empty’ => false, ) ); usort( $allcities, … Read more