get term id from term name

Try to use get_term_by(), where first argument is a field, in your case – name. Second is your value. I used esc_attr() to make it secure. Third one is taxonomy, as example I put here category. if ($_SERVER[“REQUEST_METHOD”] == “GET” && $_GET[‘fname2’] && $_GET[‘fname’]) { $nameb = get_term_by(‘name’, esc_attr($_GET[‘fname2’]), ‘category’); $namea = get_term_by(‘name’, esc_attr($_GET[‘fname’]), ‘category’); … Read more

Tax query with multiple terms in pre_get_posts

Just use: ‘terms’ => $rt_cat_id I’ll work for both array and single-based values. Or you can simplify your code as follows: if( isset( $_GET[ ‘listing_cat’ ] ) ) { $tax_query[] = array( ‘taxonomy’ => ‘listing_category’, ‘field’ => ‘id’, ‘terms’ => $_GET[ ‘listing_cat’ ] ); }

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