Questions tagged [taxonomy-terms]

Terms are usually associated to custom taxonomies in Wordpress

Use this tag if you mean terms used for custom taxonomies in Wordpress

486 questions
20
votes
3 answers

Wordpress- How to get term name from term_ID?

I'm trying to retrieve term names from taxonomies for $title. I have come across a lot Codex functions like get_post_meta(), get_the_terms() etc, which seem to only get term name from post_id, which is not what I'm looking for. How do I get term…
joe city
  • 349
  • 1
  • 3
  • 9
9
votes
2 answers

Get all product categories in WooCommerce

I am trying to get product categories in WooCommerce, but get_terms() function doesn't work for me. I am getting an empty array. What I am doing wrong? How to get all Woocommerce product category terms?
8
votes
1 answer

Add Product Attributes with values to a product in Woocommerce

I am using this code to add custom attributes $attributes = array( array("name"=>"Size","options"=>array("S","L","XL","XXL"),"position"=>1,"visible"=>1,"variation"=>1), …
8
votes
2 answers

Wordpress: tax_query multiple terms using OR operator

Simple query but for some reason is not displaying the correct posts, trying to display a post with the monthly-to-do-list term, if no results then display a post with the community-events' term. Any suggestions? $todo_args = array( 'cat' =>…
Jose Salazar
  • 341
  • 1
  • 4
  • 12
8
votes
7 answers

get_terms() orderby name is not working - wordpress

I'm using wordpress, want first-level taxonomy terms to be ordered by name but below code is not giving me desired result. Here is my code: $args = array( 'taxonomy' => 'tax-category', 'hide_empty' => 0, 'hierarchical' => 1, …
aiddev
  • 1,409
  • 2
  • 24
  • 56
7
votes
2 answers

Wordpress - Get tag id by slug

I am trying to get id\name of tag by it slug. Thats my code: $tag = get_term_by('slug', 'hedoms', 'post_tag'); $tag_id = $tag->term_id;

name;?>

I took it from…
Oshrib
  • 1,789
  • 12
  • 40
  • 67
7
votes
1 answer

Uncaught Error: Cannot use object of type WP_Term as array

I had this issue since I updated my WordPress, in my website I have a custom post which contains some custom categories, something like that: 1) Parent category: Food | Child: Fries, Hamburger, Maple Syrup… 2) Parent category: Year | Child:…
cbtr
  • 95
  • 1
  • 2
  • 6
7
votes
4 answers

Display the terms or product attributes for a specific product category(woocommerce)

I have been researching all over the net and forums regarding my question but I can't seem to produce the correct results. Basically I'm trying to display the terms or product attributes for only a specific product category. Here is the code I have…
clestcruz
  • 1,081
  • 3
  • 31
  • 75
5
votes
1 answer

Auto select first available options from a variation on WooCommerce variable products

I have a t-shirt product that has a choice of sizes and colours. After selecting of one variation I would like the first available option to be auto selected in the other variation. For example, if I had a white t-shirt with only Large and Extra…
5
votes
2 answers

WooCommerce replace "Available on backorder" in cart/checkout based on product category

I wrote some code for displaying a custom backorder message on the product detail page which is based on the product category. function custom_backorder_message( $text, $product ){ if ( $product->managing_stock() && $product->is_on_backorder( 1…
4
votes
1 answer

Exclude products with specific attributes terms from WooCommerce coupons

I would like to exclude from all WooCommerce coupons the products that have a specific attribute (e.g. attribute_pa_brand => mybrand). I followed this answer Exclude variations with 2 specific attribute terms from coupon usage in Woocommerce but it…
SierraEcho
  • 151
  • 1
  • 12
4
votes
2 answers

Getting all the product attributes and their terms in WooCommerce

I have researched this all day but cant seem to get a straight answer how can I get the set product attributes along with the configured terms for each? This is what I have now //get the terms $attribute_taxonomies =…
Stanley Ngumo
  • 4,089
  • 8
  • 44
  • 64
4
votes
1 answer

Show WooCommerce product tag name set for a product with a shortcode

As the title says I’m looking for a shortcode I can use to show the tag of a specific product. All my products have only one product tag set for each. For example, if the product with ID: 1250 has the tag “Horse” I need the way to put a shortcode…
4
votes
1 answer

Display current category first then child categories in WooCommerce

I'm trying to display in the sidebar the current page's category and it's subcategories. The title should be the current category's name and linked to the current category as well. An example of what I'm trying to achieve can be seen here in the…
Felicia Santos
  • 401
  • 3
  • 16
4
votes
1 answer

Add a prefix to WooCommerce product titles based on categories

Is there any chance to have a prefix title for specific categories of woocommerce products? For example: If I add an RTX 2080Ti to GPU Category the title needs to be [GPU] RTX 2080Ti. I have tried many codes around the internet but couldn't reach…
1
2 3
32 33