How do I get the current tag out of a taxonomy?

What you are looking for is get_the_terms(). You can get custom terms for the current post by using the following code: $post_tags = get_the_terms(get_the_ID(), ‘portfolio_tags_client’); if ($post_tags) { ?> <div class=”tags-div”> <h3><?php _e( ‘Tags’, ‘text-domain’ ); ?></h3> <div class=”post-tags”><?php foreach($post_tags as $tag) { echo ‘<a href=”‘.get_tag_link($tag->term_id).'” title=”‘.$tag->name.'”>’. $tag->name .'</a>’; } ?> </div> </div><?php } This … Read more

get_terms() order by term_meta

the order doesn’t seem to follow the meta value Yes, and it’s because you set the meta key like this: (which doesn’t actually set the meta key) array( ‘key’ => ‘order’, ), The proper way is by using the meta_key parameter: ‘meta_key’ => ‘order’ So the full code would be: $type_terms = get_terms( ‘type’, array( … Read more

Retrieve taxonomies from arbitrary site

how can I retrieve all taxonomy terms for a post in an arbitrary site programmatically? In other words, given post $post and site $siteId, how can I retrieve all terms for all taxonomies of that post in that site? You can do this by omitting the taxonomy from WP_Term_Query: $query = new WP_Term_Query( [ ‘object_ids’ … Read more

Is it possible to get_terms by author?

Not directly, because terms are assigned to posts, not authors. You will need to query all posts, get their terms and authors, and then filter out terms which came with posts that have other authors than get_query_var(‘author’). Note that depending on the number of posts your site has, this kind of query could be very … Read more

WordPress built-in method to extract array of term IDs?

I know you’ve long since solved this, but wanted to offer another solution. This question popped up as “related” when I was answering another one. You can use the WordPress function wp_list_pluck to return an array with values as one of the fields of the array or objects sent to the function. In other words, … Read more