---
title: "Related Categories: Developer Hooks and Filters Reference"
description: "Developer reference for Related Categories for WooCommerce: filters, actions and the relate options array."
url: "https://wpfactory.com/docs/related-categories-hooks-filters/"
updated: "2026-09-26"
category: Developers
---

# Related Categories: Developer Hooks and Filters Reference

## Developer hooks and filters reference

This reference lists the actions and filters exposed by [Related Categories for WooCommerce](https://wpfactory.com/item/related-categories-for-woocommerce/), so you can adjust which categories are related and hook into the plugin from your own code. Hook names are given exactly as they appear in the source.

### Filters

| Filter | Arguments | Purpose |
| --- | --- | --- |
| `alg_wc_related_categories_single` | `$related_categories`, `$product`, `$relate_options` | Final list of related category IDs for a single product. |
| `alg_wc_related_categories_loop` | `$related_categories`, `$product_category_id`, `$relate_options` | Final list of related category IDs on archive pages. |
| `alg_wc_related_categories` | `$related_categories`, `$product_category_id`, `$relate_options` | Related IDs after each source category is processed (runs for both single and archives). |
| `alg_wc_related_categories_single_product_category_ids` | `$product_category_ids`, `$product` | The product's source category IDs before relations are computed. |
| `alg_wc_related_categories_before_single` | `$value` (default `false`) | Return an array of IDs to supply the related categories directly and skip the automatic logic. |
| `alg_wc_related_categories_before_single_override` | `$do_override`, `$related_categories`, `$product` | Whether the value from the filter above replaces (true) or merges with the automatic list. |
| `alg_wc_related_categories_per_product_id` | `$product_id` | The product ID used to read per-product manual relations (used for multi-language mapping). |
| `alg_wc_related_categories_per_term_id` | `$term_id` | The term ID used to read per-term manual relations (used for multi-language mapping). |

### Actions

| Action | Arguments | Fires |
| --- | --- | --- |
| `alg_wc_related_categories_core_loaded` | `$core` | After the core class is instantiated and options are loaded. |
| `alg_wc_related_categories_after_save_settings` | (none) | After the settings are saved on any sub-tab. |

### The relate options array

The `$relate_options` argument passed to the category filters is an associative array of booleans describing the active Relate Options, for example `siblings`, `parents`, `children`, `current` and `per_category`, plus the include sub-flags such as `siblings_include_grandparents`. Use it to branch your logic based on how the store owner configured the plugin.

### Examples

Exclude a specific category (for example ID 42) from the related list on single product pages:

```
add_filter( 'alg_wc_related_categories_single', function( $related_categories, $product, $relate_options ) {
    return array_values( array_diff( $related_categories, array( 42 ) ) );
}, 10, 3 );
```

Supply the related categories yourself and replace the automatic logic:

```
add_filter( 'alg_wc_related_categories_before_single', function( $value ) {
    return array( 15, 16, 17 ); // category term IDs
} );

add_filter( 'alg_wc_related_categories_before_single_override', '__return_true' );
```

### Need a hand?

Our team answers every ticket on the [Related Categories support forum](https://wpfactory.com/support/item/related-categories-for-woocommerce/).

Related articles

- [Display Related Categories with the Widget](https://wpfactory.com/docs/woocommerce-related-categories-widget/)
- [Related Categories Shortcodes](https://wpfactory.com/docs/woocommerce-related-categories-shortcodes/)
- [Relate Options: How Related Categories Are Chosen](https://wpfactory.com/docs/woocommerce-related-categories-relate-options/)
- [Translate Related Categories with WPML and Polylang](https://wpfactory.com/docs/related-categories-multilingual-wpml-polylang/)
- [Additional Tips for Testing Related Categories](https://wpfactory.com/docs/additional-tips-cat/)
