Get taxonomy name for the current post

You should no longer use the legacy function parameter format. Instead, as the documentation says, use the get_terms( $args ) format: Since 4.5.0, taxonomies should be passed via the ‘taxonomy’ argument in the $args array: $terms = get_terms( array( ‘taxonomy’ => ‘post_tag’, ‘hide_empty’ => false, ) ); And as for getting only the terms assigned … Read more

Get Child Category only

So if I understand correctly, the problem here is that get_the_terms(..) returns both the parent and child category. As you said in the comment, there will only ever be 1 parent and 1 child in it, we can use that information to get the correct term. Basically we need to filter the results, we know … Read more

Get taxonomy singular name instead of taxonomy slug inside $taxonomy query

get_object_taxonomies() by default returns a list of taxonomy names like category and post_tag. If you want the function to return taxonomy objects instead, then set the second parameter to objects: $taxonomies = get_object_taxonomies($custom_post_type_name, ‘objects’); And then change your foreach () code to foreach ($taxonomies as $taxonomy => $tax_object), then use $tax_object->labels->singular_name to access the singular … Read more

Query all post and CPT from 2 specific taxonomies AND by ACF custom field

Finally I found a solution! Here is the query in case someone needs it : // first query $first_ids = get_posts(array( ‘fields’ => ‘ids’, ‘posts_per_page’ => ’10’, ‘post_status’ => ‘publish’, ‘post_type’ => array(‘post’), ‘orderby’ => ‘date’, ‘order’ => ‘DESC’, )); // second query $second_ids = get_posts(array( ‘fields’ => ‘ids’, ‘posts_per_page’ => ’10’, ‘post_status’ => ‘publish’, … Read more

Get term from multiple taxonomy

Your get_terms is causing a parse error, you are missing the array part. Also when using get_terms take into account that by default it will not return taxonomies that don’t have posts attached to them. The proper code would be like this $terms = get_terms([ ‘taxonomy’ => [ ‘category’, ‘profile_status’, ‘profile_skill’ ] ]); If you … Read more

How to filter custom taxonomy term name, slug, and description?

The default fields name, slug and description are not term metadata, so you should instead use wp_update_term() to update those fields. So just replace those three add_term_meta() with: wp_update_term( $term_id, ‘codes’, [ ‘name’ => $name, ‘slug’ => $slug, ‘description’ => $desc, ] ); Additionally, instead of using $_POST, I would use get_term() to get the … Read more

Display sibling categories on category page

I have a category page, how do i display this category sibling categories on this page as well? I know how to display children categories I think i need to get term_id somehow On a term archive page, e.g. at example.com/category/foo/ (for the default category taxonomy), You can use get_queried_object() to retrieve the term object … Read more