Questions tagged [custom-taxonomy]

3

votes
3

answer
516

Views

Show count of Custom Taxonomy only for a specific Custom Post Type

I want to display the count of a Custom Taxonomy based on a specific Custom Post Type. At the moment, I'm using get_terms to list all terms of the Taxonomy. The Taxonomy is used by more than one Post Type. So the counter shows all the usage of the Taxonomy for every Post Type. Is there a way to limi...
Cray
3

votes
1

answer
17

Views

Exclude a product category from Related products in WooCommerce

I am trying to exclude a product category (id: 78) from the related products section in WooCommerce. I have a custom query already in place which only shows related products from the child category. This is my code:
dwinnbrown
1

votes
2

answer
450

Views

Wordpress - Get the taxonomy of a post hierarchically

I would like to get all the taxonomy of one post (in a loop), hierarchically. Example I have those taxonomies, and the ID of the tax in bracket. Tax1(1) -Tax2(3) --Tax3(2) I would like to gather them, in an array maybe, in this order. Right now I manage to get an array of those 3, but the order is w...
Antoine Dionne
1

votes
2

answer
1.2k

Views

custom taxonomy image option in admin panel

I have created a custom taxonomy and want to have a image option for each category. function create_product_taxonomies() { // Add new taxonomy, make it hierarchical (like categories) $labels = array( 'name' => _x('product_categories', 'taxonomy general name'), 'singular_name' => _x('Product', 'taxon...
Waqas_aamer
1

votes
2

answer
754

Views

WordPress: Why Can't get_terms() See Custom Taxonomy Registered inside Class?

Background I register a custom post type and custom taxonomy inside a class. Inside the WP admin, I see both the post type, and I see the taxonomy. Simplified Code: class Custom_Post_Type { function __construct($init_data) { if ( is_admin() ) { add_action( 'init', array( $this, 'create_ctp' ) ); add...
Andy Mercer
1

votes
1

answer
3.8k

Views

Wordpress - get_terms() returns “invalid taxonomy” (this is not a hook issue)

On my local machine it works fine, but on the live server, when I run get_terms('taxonomy' => 'any_taxonomy'); it returns a list of terms, but if I add any parameter to it like: get_terms('taxonomy' => 'any_taxonomy','hide_empty' => false); Then it returns 'invalid taxonomy'. The issue is not that...
John Slotsky
1

votes
1

answer
245

Views

Display posts tagged with a specific term

I am attempting to display all the posts that tagged to specific terms in WordPress, at the moment it's displaying all my posts in the custom post type rather than the posts tagged to each term. I have a file called taxonomy-clientType.php and then here is the code I use to try fill my WP_Query with...
pocockn
1

votes
2

answer
143

Views

Displaying a custom post from a custom taxonomy

I made a custom taxonomy: function project_register_taxonomy(){ $singular = 'Project Categories'; $plural = 'Projects Categories'; $slug = str_replace( ' ', '_', strtolower( $singular ) ); $labels = array( 'name' => $plural, 'singular_name' => $singular, 'search_it...
Ozzy
1

votes
1

answer
809

Views

Change cart item prices for specific product categories in Woocommerce

I would like to change regular price to custom price of products in the cart for specific categories only ('t-shirts-d','socks-d','joggers-d','boxers-d') as each of the products share 2 different categories. I tried doing so and it worked but the custom price affects on other categories too, and I...
SandeepTete
1

votes
2

answer
984

Views

Creating WooCommerce product variation adds an empty attribute value

When adding variations to a WooCommerce product it is adding in a blank attribute. Meaning that when I try to add in my own attribute it gets appended to an existing array. Example code I am running: $product_variation = wc_get_product( $variation_id ); $product_variation->set_attributes(array('attr...
Simon Pollard
1

votes
1

answer
955

Views

Sort Woocommerce Products from a product category and custom meta_key

Im successfully filtering ALL my Wordpress posts by Likes (count) with a Custom Plugin (and meta_key) wich also let me filter the most liked posts in categories. I display (query) the result in a custom page template. Everything works fine. The Like function works also on Woocommerce Products. But...
evavienna
1

votes
2

answer
2.9k

Views

Customizing product categories breadcrumb links in Woocommerce via the theme

I am trying to modify class-wc-breadcrumb.php to customize the product category links in the breadcrumb of my products pages. This file is located in : wp-content/plugins/woocommerce/includes I tried to copy and edit this file in my child theme into: wp-content/themes/Divi-child/woocommerce/include...
AlbertoV
1

votes
2

answer
132

Views

Display Clickable list of a specific taxonomy in my custom post type

I'm having a hard time even coming up with a title for this. If I'm editing the code for a regulator old blog post (content.php) and add I get a clickable list of all the categories that post belong to. I have a custom post type called research and a custom taxonomy associated with it called topics...
mwz
1

votes
1

answer
2.1k

Views

Using a custom single product template for a specific product category in Woocommerce

I'm trying to use a custom page for only one of the products in the woocommerce shop. I've been trying to apply the attached function but without success (which code is coming from this answer). I have a created a copy of the single-product.php file in my /woocommerce folder with some added code, bu...
1

votes
1

answer
261

Views

woocommerce storefront excluding categories from homepage

On the storefront homepage template 3 categories are displayed. I can change some aspects, e.g. hide empty and order. What I want to do is either include or exclude specific categories, probably by their id. function my_edit_storefront_category( $args ) { $args['number'] = 10; // works $args['exclud...
marcovanbostin
1

votes
1

answer
1.2k

Views

Excluding product categories from shop page in Woocommerce

I am trying to hide a product category from my product category menu. add_filter( 'woocommerce_product_categories_widget_args', __NAMESPACE__ . '\\rv_exclude_wc_widget_categories' ); function rv_exclude_wc_widget_categories( $cat_args ) { $cat_args['exclude'] = array('129'); // Insert the product ca...
benjiiiii
1

votes
1

answer
95

Views

Check a product category for a product in Woocommerce

I want to check the category of a WooCommerce product post right after it's created(or updated) and then run some more code based on the category. To check post on creation/update I used save_post and for category has_category. Something goes wrong with has_category and it doesn't return anything at...
Zae
1

votes
2

answer
1.2k

Views

Woocommerce products from category loop

In Woocommerce, I Need some help with this custom product loop, in my code my result is : how it looks like The loop doesn't stop and it is looping the same products for three or four times. The code I am using is here :
Aurimas Gelžinis
1

votes
1

answer
410

Views

Get specific product attribute and display it in Woocommerce Single Product Pages

I have created an attribute called 'dimensions' I wish to add a snippet that will :- Display the dimensions attribute (Label and Value) in the single product page under meta.
Alex Trainor
1

votes
1

answer
1.3k

Views

How to check if product has a specific product attribute in Woocommerce

I would like to identify if a product has an attribute or not. For example: if (product has attribute 'pa_color') { //do something } How can I accomplish this?
Vpant
1

votes
2

answer
2k

Views

Change default sorting for specific Woocommerce product category archive pages

I need to change the default product sorting option to 'Newness' for a specific product category on my site. I know you can go to WooCommerce > Settings > Product > Display to globally change the default sorting option, but thats not what I need to do. I need something like: function change_default_...
Seb G
1

votes
1

answer
783

Views

Get specific product attribute values for a specific product category in Woocommerce

I have already managed to get all the color attributes with this code: $color_terms = get_terms( array( 'taxonmy'=>'pa_color' )); This works fine for Shop page and returns all the colors but how can I limit it to a certain category? Lets say in a category named 'Shirts' I have only 2 colors and I...
user7432810
1

votes
1

answer
866

Views

Hide specific shipping options based on products or categories in WooCommerce

My WooCommerce website uses 3 different shipping types. Royal mail signed for (7 days) Next day guaranteed Recorded delivery Some products can only be shipped using option 1. When this product is added to the cart, a shipping class i created helps to show option 1 in the cart but the other two optio...
user2770714
1

votes
1

answer
38

Views
1

votes
4

answer
258

Views

Add a body class for product category archive page in Woocommerce

I want to add product category slug in the body class on product category archive pages. Here is an example of what I would like (url of the product category page example): https://example.com/product-category/canon/… So I would like 'canon' in the body class.
Benjamin Dajao
1

votes
1

answer
187

Views

Disable some product categories from Woocommerce category dropdown widget

I'm searching for a solution to hide specific categories in the standard woocommerce category widget that is in the sidebar on the shop page, i'm using the dropdown. I've searched but can seem to find it anywhere, tried en rebuild multiple scripts but cant seem to figure it out.. Thanks in advance
RMCS
1

votes
1

answer
40

Views

Display only a single linked product category text on any page in Woocommerce

I need to show different product categories on several regular pages but can't find a suitable shortcode for that. Which shortcode do I have to use to show only single product category (without showing any products from that category) on any page? Any help is appreciated.
Roger Wayne
1

votes
1

answer
55

Views

How to get the post term name of a custom taxonomy in Woocommerce

In Woocommerce, I am trying to change (add some) in plugin file Retailcrm для wordpress/woocommerce, Github Especially the part that will allow me to add the name of the custom taxonomy of the product (related to the manufacturer) to xml. The problem is that something is wrong with my code, I ca...
kh1
1

votes
1

answer
287

Views

Add a new term to a product attribute and set it in the product in Woocommerce

My custom taxonomy (WooCommerce attribute) already exists and I am using the following to add a new term to the taxonomy and associate it with my WooCommerce product: wp_set_object_terms($product_id, array($omega_jahr), 'pa_years-of-construction'); When I use the following to call the 'pa_years_of_c...
Richard Tinkler
1

votes
4

answer
1.8k

Views

Can a term have multiple parents from different vocabularies?

Is it possible in Drupal Taxonomy? I've many pages related to consumer products to be in following vocabularies: Electronics Washing maching TV Mobile Cars Electrical ... all sorts of Now Sony TV would go in TV and also in Electronics. Is it possible to do it in Taxonomy ie to inherit from multiple...
AgA
1

votes
2

answer
2.5k

Views

Gem for taxonomy / user-defined fields

Is there an existing gem for adding user-defined field functionality to an existing Ruby class? Two examples of the type of gem/solution I'm looking for are: Rails custom meta model? Rails - Adding Custom Fields at runtime in ActiveRecord ...and ultimately I'd like to allow users to build their own...
jefflunt
0

votes
0

answer
6

Views

Check if a custom select field is working on WordPress custom taxonomy

I've got this code which adds a select field called 'comp_email_template_id' to my custom taxonomy called 'xyz_comp_entry_category'... add_action( 'xyz_comp_entry_category_add_form_fields', 'xyz_comp_entry_category_form_custom_field_add', 10 ); add_action( 'xyz_comp_entry_category_edit_form_fields',...
user3256143
1

votes
0

answer
6

Views

Unable to access tags of custom post type?

I have created a custom post type named 'blogs'. $labels = array( 'name' => _x( 'Blogs', 'post type general name', 'your-plugin-textdomain' ), 'singular_name' => _x( 'blog', 'post type singular name', 'your-plugin-textdomain' ), 'menu_name' => _x( 'Blogs', 'admin menu', '...
Gufran Hasan
0

votes
0

answer
4

Views

where should i link my custom post type taxonomies?

I'm a newbie and trying to create my own Wordpress Theme. I have created Custom Post Types named 'Works' and a Taxonomy named 'Categories' (with tags as 'Custom CMS', 'Wordpress' ect) I want each work to dislay his categories, and to link to a page with all simular Works. This is my code: $terms = g...
Giannis
1

votes
1

answer
391

Views

Use Taxonomy ACF to affect Custom Taxonomy post count

Is there a way to use an 'ACF Taxonomy Field' to affect 'Custom Taxonomy' post count? Right now I am using ACF Taxonomy Field, but my Custom Taxonomies have 0 posts assigned. I want to use ACF to assign Custom Post to Custom Taxonomy: Instead of the default way: Is this possible? I'm trying to do th...
Jabel Márquez
1

votes
1

answer
686

Views

How to filter taxonomy args with register_taxonomy_args WordPress

I am trying to filter the taxonomy args on a selection of custom taxonomies with the register_taxonomy_args filter hook. However when doing so I am getting quite a lot of error messages. To list a few: Warning: Missing argument 2 for edit_bb_taxonomy_args() in /Applications/MAMP/htdocs/broadbean/wp-...
James Koussertari
3

votes
1

answer
42

Views

Set a product category term in a product on Woocommerce

In Woocommerce I have a Product Attribute called 'Platform' the Value of the Attribute is 'Steam': So I am bulk importing the products and the Attributes are already there. But now I have to set for every product manually the category. Is it possible to set the Value automatically as Product Catego...
M6Gpower
3

votes
1

answer
24

Views

Get products which are visible in catalog in a WP_query on Woocommerce

I'm currently trying to get all products in a category page which are visible in catalog. I've tried this here but I'm getting no products with this query: $args = array( 'post_type' => 'product', 'product_cat' => get_queried_object()->slug, 'meta_query' => array( array( 'key' => '_visibility...
Mr. Jo
1

votes
1

answer
3.7k

Views

How to change value for 'options' and 'select' in wp_dropdown_categories?

I am currently using this code to display only the child terms of the current category being viewed - I need to be able to add values and classes to the 's and the opening . How can I modify the above code to do so? Im not sure but I think Im getting close. -
Rich
2

votes
2

answer
1.1k

Views

Get the product category name and description in Woocommerce Single Product page

I've been using the WooCommerce Codex, but I can't seem to get the data to display. I simply want to display the product category and descriptions to display on single product pages for my own custom layout like so.
GibsonFX

View additional questions