Add Custom CSS to Woocommerce Product Page in a specified category

Here’s my solution… Added the following to functions.php in my child theme: add_filter( ‘body_class’,’my_body_classes2′ ); function my_body_classes2( $classes ) { if ( is_product() ) { global $post; $terms = get_the_terms( $post->ID, ‘product_cat’ ); foreach ($terms as $term) { $product_cat_id = $term->term_id; $classes[] = ‘product-in-cat-‘ . $product_cat_id; } } return $classes; } Now whenever you’re viewing … Read more

Hide uncategorized products from the shop page

I solved this problem based on code kindly provided by rynoldos (https://gist.github.com/rynaldos/a9d357b1e3791afd9bea48833ff95994) as follows: Include the following code in your functions.php file: /** Remove categories from shop and other pages * in Woocommerce */ function wc_hide_selected_terms( $terms, $taxonomies, $args ) { $new_terms = array(); if ( in_array( ‘product_cat’, $taxonomies ) && !is_admin() && is_shop() ) … Read more

How to show “Previous Category” and “Next Category” in categories archieve template [closed]

This is about PHP, not about WordPress, but here you go: get_categories returns a simple array of categories, not an indexed array. Your foreach loop tries to adress it as an indexed array. Hence the error. Also, $position becomes an undefined variable, and the loop is unnecessary anyway. $position = array_search ($this_category->term_id, $categories); $next_cat = … Read more

pre_get_posts with WooCommerce Shortcode Query

You could use the WooCommerce filter woocommerce_shortcode_products_query to change/manipulate the query arguments. This example comes from the shortcode documentation. When using the Products shortcode, you can choose to order products by the pre-defined values above. You can also sort products by custom meta fields using the code below (in this example we order product by … Read more

How does WooCommerce display a custom comment_type in Comment Admin?

To answer your first question: »How does WooCommerce add the comment_type of order_note to the dropdown in Comment Administration?«. From woocommerce-admin-init.php: function woocommerce_admin_comment_types_dropdown( $types ) { $types[‘order_note’] = __( ‘Order notes’, ‘woocommerce’ ); return $types; } add_filter( ‘admin_comment_types_dropdown’, ‘woocommerce_admin_comment_types_dropdown’ ); Of course you have to do your own, to avoid conflicts, like this: add_filter( ‘admin_comment_types_dropdown’, … Read more