I figured out what the issue was. The page was displaying categories/subcategories and not the items themselves. This meant that woocommerce_product_subcategories()
was the one filtering and that uses a different hook.
Here is what I added to my functions.php
file.
add_filter( 'get_terms', 'get_subcategory_terms', 10, 3 );
function get_subcategory_terms( $terms, $taxonomies, $args ) {
$new_terms = array();
// if a product category and on the shop page
if ( in_array( 'product_cat', $taxonomies ) && ! is_admin() && is_shop() && isset($_SESSION['mid']) ) {
foreach ( $terms as $key => $term ) {
if ( in_array( $term->slug, array( $_SESSION['mid'] ) ) ) {
$new_terms[] = $term;
}
}
$terms = $new_terms;
}
return $terms;
}
Related Posts:
- Filter WooCommerce archive pages by an additional category
- How do I edit pre_get_post for the category the user is currently in?
- Display all product tags associated with a specific product category
- Restrict retrieved terms by category?
- No results found for second level category
- Display All Products by Category with WooCommerce
- Woocommerce get category image full size
- How to tax query X number of posts related by tag first, then by category if not enough in tag-related
- Make parent categories not selectable
- Reflect nested categories in appearance > menus
- Remove child products from woocommerce category page [closed]
- Display WooCommerce product categories in a 4 columns custom menu [closed]
- How to select product category while adding new product in woocommerce? [closed]
- Can paginate_links() be customized for a specific category or tag?
- Add Icons to the Product Category Sidebar Widget WooCommerce
- Add Product categories to WordPress menu without losing hierarchy
- Category archive page – loop through posts of certain tag (with pagination) – pre_get_posts
- Display “add to cart” button on every listing in product category page?
- Make parent category not selectable when it has child categories
- Getting categories id for all products in cart
- Hide posts of a certain category unless logged in
- What’s the Simplest Way to Override/Rewrite the %category% Permalink Structure Tag?
- get_cat_ID() not wokring
- How to Filter categories in the permalink structure
- How to display posts under a specific subcategory of a given category
- Taxonomy filter all children
- Categorising posts/pages into years published
- Woocommerce category show subcategories only/omit posts for specific category
- products nested by subcategories in a current category archive
- WC 3.x Get categories from variable product of the cart
- Automatically set default password to all posts in a specific category
- get_the_categories filter returns an empty array
- category filter doesn’t work in WPML
- Hide woocommerce category name from specific pages
- Pagination not visible on woocommerce’s category page
- Remove product category placeholder image (Woocomerce)
- Change thumbnail image depending product category
- Unwanted Duplicate Product Categories in WooCommerce
- How to organize custom categories for filtering and selecting
- Woocommerce custom category pages
- Customize WordPress widget – Product Category
- WordPress/Woocommerce only show category in shop to a single role
- Refine/Filter the Search Results by Category
- Pagination for ajax category filter
- How to hide category name
- Categories are not listing their respective products
- Woocommerce: Complex query in pre_get_posts [closed]
- Display single category name in woocommerce loop
- Include WooCommerce product to all child categories
- woocommerce related products by specific categories [closed]
- How to make the ‘delete’ button inactive on some categories?
- List a maximum of ‘x’ product categories with qty of ‘y’ in each column
- Apply WordPress function on specific woocommerce product categories only
- Woocommerce filter function not updating
- Adding custom ID field to the categories
- How can i change what one category displays?
- How to hide some categories in dashboard
- How to display product with two condition, category and brand taxonomy
- Show different menu on each woocommerce category page
- How can I filter posts by tag on the fly
- Exclude posts without category from loop
- WooCommerce shared categories
- category description not showing in my woocommerce
- Sort categories by custom field in WordPress admin
- How to filter tags by category?
- How to make product image inherit from category image
- How to show given products only using product id array from specific category page in woocommerce
- Custom Taxonomy Isotope Grid – Filter Buttons Not Working
- Shop Category Pages missing s
- How to set acf color field as background color to product category
- How to target all woocommerce categories that don’t have any subcategories in them?
- Show the parent taxonomy by creating shortcode in woocommerce?
- How to add all subcategories as submenu in WordPress menu
- When creating a new product, auto assign it to all custom taxonomy woocommerce
- in post content shortcode works, but hardcoded in same page template doesn’t?
- Correct Hook/Filter to amend category choices on post edit page
- How to fix 404 error in pagination in categories of woocommerce with common url base /shop/?
- How to display custom fields as table in Woocommerce
- How do I merge WooCommerce categories with the same name?
- Change post category within pre_get_posts
- How to delete WooCommerce categories in bulk that only have one product
- Product Category page showing all products
- How to load terms of a custom taxonomy of a product in woocommerce cart page
- product_cat image url from database
- Woocommerce product catalog, products with different description
- WooCommerce – Get products from category right before deleting category
- How to display products with multiple conditions, product_id and category_id
- Categories and Tags Conflict after Woocommerce Installation
- ACF Gallery with Media Categories – how do display categories and sort
- How to get related category/categories in WordPress archive page
- Display related posts with same category or same tag return blank
- Custom Woocommerce Category view
- Displaying categories and subcategories without link
- Sorting Woocommerce products by category and attributes
- How to get Woocomerce categories count
- Woocommerce – Display product category of product in Orders page
- Changing Woocommerce categories programatically
- Categories and products woocommerce wordpress
- How to create a photo gallery that can be filtered by the image categories
- Restricted category in Woocommerce [closed]