Questions tagged [taxonomy-terms]

1

votes
0

answer
33

Views

How to update a category after update a post in WordPress?

I have a custom post type named Beaches. A category is created every time a post is created, this is working. My category has the same title and the same slug as the post type. The problem is when a post is updated, I can't link the post to the category anymore, if the title and the slug changes. Th...
Italo Borges
1

votes
0

answer
57

Views

Pagination on “get_term_children” - Wordpress

I would like to get a pager in my page, can i create a pager with a for each or while without parameter like 'posts_per_page' ? I get term children of my taxonomy and i would like to display 3 by 3 My code : $childGalerie = get_term_children(15,'wpmf-category'); foreach ( $childGalerie as $oneGal...
Syneria Fana
1

votes
0

answer
57

Views

WordPress - Display categories, duplicate parent item and show as a child if there are children

I'm having issues with customising the Custom Walker. What i'm trying to do is create an accordion menu where the first parent opens up the child list which also as the parent repeated so it can be clicked on. Parent 1 - Parent 1 - Child 1 - Child 2 Parent 2 - Parent 2 - Child 1 - Child 2 - Child 3...
ragu.design
1

votes
1

answer
270

Views

How exclude one term from get_terms

I am showing a list of terms from a taxonomy and need to exclude a term from the list how do I do this? I made the code below but did not delete it. $terms = get_terms( 'taxonomyespecialidades', array( 'orderby' => 'name', 'order' => 'ASC', 'exclude' => array(), ) ); $exclude = array('Acupuntura...
J.Z
1

votes
1

answer
192

Views

How to get real term_meta using ACF with custom fields on taxonomy terms (instead of wp_options)

Having a simple Woocommerce site, I'm using ACF pro to add some custom fields to the terms of a given taxonomy. Using this, I can, for example, add a 'color' field to my 'product category' taxonomy terms. Good. The issue: Wanting to do some query using get_terms() (codex), I discovered that my meta...
Mtxz
1

votes
0

answer
70

Views

Woocommerce product attributes not queried with get_terms()

When I try to query my custom product attributes using get_terms(array( 'taxonomy' => array('pa_kolor'), 'hide_empty' => false )); It's working just fine. However, when I add any additional taxonomies, for example: get_terms(array( 'taxonomy' => array('category', 'pa_kolor', 'product_cat'), 'hide_e...
Tomasz Lisek
1

votes
1

answer
55

Views

Display for a specific WooCommerce product attribute the terms list on a page

In Woocommerce, I am trying to create a simple page with all brands that I have from product attribute pa_brand. But I didn't find the correct way to make that. So this page needs to show linked brands names as a list. Any track will be appreciated?
watcher_sk
1

votes
1

answer
17

Views

Display New Badge Woocommerce If In New Category

I need to display a 'new' badge to product on the archive page but only for products in the 'New' category add_action( 'woocommerce_after_shop_loop_item_title', 'lottie_new_badge', 40 ); function lottie_new_badge($badge) { global $product; if (has_term ('new')) { echo 'New'; } return $badge; } Got t...
FoamyMedia
1

votes
2

answer
37

Views

Single Woocommerce product custom variations add to cart buttons

I have customized WoCommerce single product page and added a cart button using simply this line echo woocommerce_simple_add_to_cart(); but now I need two added two cart button for two types of variation. My all attribute and child is same. type_of_audio and child is mac & windows. All I want to crea...
N Hossain
1

votes
0

answer
9

Views

meta_box_cb function dropdown creates another term on post save

I have a callback 'cities_meta_box' which is a dropdown. public function cities_meta_box($post, $box) { $defaults = array('taxonomy' => 'category'); if (!isset($box['args']) || !is_array($box['args'])): $args = array(); else: $args = $box['args']; endif; extract(wp_parse_args($args, $defaults), EXTR...
Amir Rami
1

votes
0

answer
21

Views

WordPress WooCommerce API: Update/insert custom taxonomy terms

I am trying to update a products custom taxonomy term via the wp-json api. I have added the below function to handle taxonomies: function wp_api_add_tax($post, $data, $update){ foreach( $data['custom_tax'] as $tax => $val ){ wp_set_post_terms( $post['ID'], $val, $tax ); } } add_filter('json_insert_p...
danyo
1

votes
0

answer
18

Views

WooCommerce shows random product attributes

In WooCommerce, I have set products with some product attributes, but I didn't add one specific attribute. This: $product->get_attribute( 'pa_material' ); works fine. If product has attributes 'material' it shows them if they are set, if not i get empty value, but when i'm using this: get_the_terms...
damiant
1

votes
0

answer
35

Views

How to display Woocommerce products sorted by product tag?

I'm building a woocommerce website using storefront. On each category page, I wish to display product ordered by tag. Each product has only one tag. TAG 1 product a product b TAG 2 product x product y I think I can retrieve all the data I need from the DB. But I have no clue how to use them to di...
user10117526
1

votes
1

answer
22

Views

Sort product attribute terms using WooCommerce wc_get_product_terms function

I have an eCommerce website powered by WooCommerce. I'm using product variations to allow my customers to choose a specific configuration for their product. I'm using the following code to list the terms names of a specific product attribute: $available_pa_colors = wc_get_product_terms( $product->ge...
Joe Sullivan
1

votes
1

answer
30

Views

Get product category for every item of a WooCommerce order

I can retrieve almost every metadata of the order items but I want to retrieve the category of the items too. My code now has this: foreach ($order->get_items() as $item_key => $item_values) { ## Using WC_Order_Item methods ## // Item ID is directly accessible from the $item_key in the foreach loop...
PelHout
1

votes
1

answer
17

Views

WooCommerce: Get purchased items for a product category using a SQL query

I am trying to list all of the products bought that belong to a certain product category, for instance all T-shirt orders under the 'clothes' product category. I find the Woocommerce database structure quite confusing and you have to write long queries to get simple information. Could anyone provide...
John Smith
1

votes
1

answer
257

Views

List custom taxonomies by custom field

Below I have my custom taxonomy template and its working fine until now.
1

votes
1

answer
299

Views

Taxonomy Term Permalink is Not Working

I have CPT called forms_cpt and a Taxonomy called forms_tax. In my page-forms.php I am able to crate a list of forms_tax terms like
Behseini
1

votes
2

answer
335

Views

Getting the 'thumbnail ID' from last product category term in WooCommerce

I am trying to add new portfolio pragmatically When I add new category in WooCommerce. My code is : function programmatically_create_post() { $author_id = 1; $taxonomy = 'product_cat'; $orderby = 'id'; $show_count = 0; // 1 for yes, 0 for no $pad_counts = 0; // 1 for yes, 0 f...
zeynab farzaneh
1

votes
2

answer
93

Views

Filter tax_query by term starting with character

I am trying to filter tax_query by term starting with some characters (i.e. STAxxxx) in WordPress WP_Query. Suppose I have below information stored at WordPress Admin: Post Type: product Taxonomy: brand Terms available for brand: Adidas, Reebok, Puma, Nike, Asics etc. If user enters 'a' into brand t...
Ramiz Manked
1

votes
1

answer
0

Views

Exclude Woocommerce products in recently viewed products widget from a product category

I'm trying to figure out how to exclude product in a category from Recently Viewed Product Widget in Woocommerce. I know products in a category can be removed/hidden from shop page using the below code function custom_pre_get_posts_query( $q ) { $tax_query = (array) $q->get( 'tax_query' ); $tax_quer...
1

votes
1

answer
0

Views

Display the product shipping class on Woocommerce single product pages

I'm trying to display the shipping class on product page but I must do something wrong because nothing shows.. I used the bellow code in function.php: add_action('woocommerce_single_product_summary', 'display_specific_shipping_class', 15 ); function display_specific_shipping_class(){ global $product...
Helen_zs
1

votes
1

answer
0

Views

Exclude a product category from Woocommerce related products

In woocommerce, I am trying to remove a specific product category from displayed related products on single product pages. I have tried to use a function hooked in woocommerce_get_related_product_cat_terms, filter hook, like in some answer threads, but it doesn't seem to work anymore. How to exclud...
Stu
1

votes
2

answer
0

Views

Hide specific products from unlogged users in WooCommerce

I have a certain product category that I only want to offer to logged in users. How would I implement that? So how to hide specific products from unlogged users in WooCommerce I've tried searching but It seems a real WooCommerce corner case.
John Smith
0

votes
0

answer
5

Views

How to customize referenced taxonomy term in custom content type form

I'm new to drupal and need some help . In drupal 8, I have a custom content type 'projet' with a field referenced a custom taxonomy term list . The taxonomy term have a title and description (default fields). In the 'add projet' form (route /node/add/projet) for the linked entity field and need to...
Julien'
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
1

answer
335

Views

Display custom taxonomy only if is not empty

I have BOOKS INFOBOX like this: Data Buku then I create genre field used by Simple Taxonomy Plugin, and I get code to display like this: My problem, how I put genre field code in BOOKS INFOBOX, and if blank data so genre field do not show?
PUSTAKAKORAN.COM
1

votes
1

answer
4.7k

Views

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' => $my_category_id, 'posts_per_page' => 1, 'tax_query' => arr...
Jose Salazar
1

votes
2

answer
765

Views

How can exclude term from get_terms by term name not by term id

My code below. It does not work to delete using the terms. I need it to work like this and not delete by ID. $terms = get_terms( 'MY_TAXONOMY', array( 'orderby' => 'name', 'order' => 'ASC', 'exclude' => array(), ) ); $exclude = array('MY TERM', 'MY TERM 2', 'MY TERM 3'); $new_the_category = '';...
J.Z
6

votes
4

answer
1.6k

Views

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 been working on.
clestcruz
3

votes
1

answer
2.5k

Views

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: 2016, 2015, 2014… 3) Parent category: Country | Child:...
cbtr
2

votes
2

answer
103

Views

over 20.000 taxonomy category issue - wordpress

I'm using wordpress. And have inserted over 20.000 product categories but now the page where I'm showing all categories is down and not available. Even in the backend - after some amount of categories, I can't see rest. And I see following errors: Fatal error: Allowed memory size of 268435456 bytes...
aiddev
2

votes
1

answer
296

Views

Wordpress - Advanced Custom Fields - Category Images wrong for Widgets

I am using Advanced Custom Fields to return the url location of Category images. Which would allow me to add the Category image before the title of the post. I have a function insert_image_before_title in my functions.php file which is referenced by a title filter (see below). So this seems to work...
truk
2

votes
1

answer
20

Views

On taxonomy page, show posts associated with that taxonomy and another

I have a custom post type called Developments. They are buildings. They have two different taxonomies: City and Status. On the City taxonomy page for one of the buildings I'm trying to show all posts associated with the Status taxonomy. $dev_name This code outputs all of the Status terms, but it's s...
Darren Bachan
2

votes
2

answer
2.4k

Views

Excluding Specific Terms from WP_Query

I would like to create a foreach loop for taxonomy terms which is for custom post type. More specifically I want a loop that queries all the products categories, but not the category 'special-offers' and not categories subcategories. Bonus would be if, product has no category query them too and orde...
Jack
2

votes
2

answer
689

Views

wp_list_categories() - display first level categories and only current term's children in subcategory page

I'm using WordPress. Have multiple categories with its subcategories. In general page, I'm displaying all first level categories. Here is my code: $args = array( 'type' => 'product-items', 'child_of' => 0, 'parent' => '', 'order' => 'DESC', 'hide_empty' => 0, 'hierarchical' => 1, 'exclude' => '',...
aiddev
2

votes
2

answer
404

Views

How to show more than 1 custom taxonomy term or link on a custom post type?

I have created a custom taxonomy called 'tema' and the taxonomy has three terms. I want to show ALL the term links that are related to the current post. Currently I can only get my code to show ONE of the posts taxonomy terms... I would like the term links displayed via my custom content.php file ('...
MariaThiim
2

votes
3

answer
205

Views

Wordpress - taxonomy used on multiple post types - how to get_terms / get_categories for just one?

I have registered taxonomies for multiple post types thinking this was the best way to set the site up rather than have the same taxonomies duplicated. However, now I have run into an issue where I need to list the used taxonomies for a post type but its listing taxonomies for all both types. Ho...
LeeTee
2

votes
1

answer
102

Views

WP_Term_Query - How to search only beginning of term name?

I'm building a WordPress autocomplete search which uses custom taxonomy terms as suggestions, and I'm using WP_Term_Query to query for the terms from what the user types in the search field. WP_Term_Query has a parameter called 'search' which according to the documentation uses the search criteria t...
Joe
1

votes
5

answer
2.6k

Views

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, 'parent' => 0, 'orderby'=>'name', 'order' => 'DESC', 'fields' => 'all', );...
aiddev

View additional questions