Actions & Filters (Hooks)

FilterX provides a comprehensive set of WordPress actions and filters to extend and customize every aspect of the plugin without modifying core files.

Plugin Lifecycle

actionfilterx/activated

Parameters: none

Fired after FilterX is activated and database tables are created.

add_action('filterx/activated', function() { // Run setup tasks });
actionfilterx/deactivated

Parameters: none

Fired when FilterX is deactivated. Tables and data are preserved.

add_action('filterx/deactivated', function() { // Clean up crons, etc. });
actionfilterx/uninstalled

Parameters: none

Fired when plugin is deleted. All tables and options are removed.

Grid Hooks

actionfilterx/grid/before_render

Parameters: $grid_id_or_slug, $args

Fires before a grid starts rendering. Useful for enqueueing dependent assets.

add_action('filterx/grid/before_render', function($grid_id, $args) { // Enqueue custom assets }, 10, 2);
actionfilterx/grid/after_render

Parameters: $grid_id_or_slug, $html, $query

Fires after grid HTML is generated. Receives the final HTML and the WP_Query object.

filterfilterx/grid/query_args

Parameters: $query_args, $grid

Filter the WP_Query arguments before the grid query runs. Add tax_query, meta_query, ordering, etc.

add_filter('filterx/grid/query_args', function($args, $grid) { $args['meta_key'] = 'featured'; $args['orderby'] = 'meta_value'; return $args; }, 10, 2);
filterfilterx/grid/html

Parameters: $html, $grid, $posts

Filter the final rendered grid HTML string before it's returned.

filterfilterx/grid/item_data

Parameters: $item_data, $post, $grid

Filter the data array for each grid item before it's passed to the grid-item template.

add_filter('filterx/grid/item_data', function($data, $post, $grid) { $data['custom_field'] = get_post_meta($post->ID, 'acf_field', true); return $data; }, 10, 3);
actionfilterx/grid/before_item

Parameters: $post, $grid, $index

Fires before each grid item is rendered.

actionfilterx/grid/after_item

Parameters: $post, $grid, $index

Fires after each grid item is rendered.

Facet Hooks

filterfilterx/facet/sources

Parameters: $sources

Register custom facet data sources. The WooCommerce integration uses this to add wc:price, wc:stock_status, etc.

add_filter('filterx/facet/sources', function($sources) { $sources['custom:brand'] = [ 'label' => 'Brand', 'type' => 'select', ]; return $sources; });
filterfilterx/facet/value_label

Parameters: $label, $value, $facet_config

Modify the display label for a facet value. Used by WooCommerce to format price labels with currency symbols.

add_filter('filterx/facet/value_label', function($label, $value, $config) { if ($config['source'] === 'wc:price') { return wc_price($value); } return $label; }, 10, 3);
actionfilterx/rest/facet_created

Parameters: $facet_id, $facet

Fires after a facet is created via the REST API.

actionfilterx/rest/facet_updated

Parameters: $facet_id, $facet

Fires after a facet is updated via the REST API.

actionfilterx/rest/facet_deleted

Parameters: $facet_id, $facet

Fires after a facet is deleted via the REST API.

Indexer Hooks

actionfilterx/indexer/reindex_facet

Parameters: $facet_id

Fires to trigger reindexing for a specific facet. Listen to this to run custom indexing logic.

add_action('filterx/indexer/reindex_facet', function($facet_id) { // Handle reindex for this facet });
filterfilterx/indexer/post_types

Parameters: $post_types

Filter the list of post types the indexer should process.

add_filter('filterx/indexer/post_types', function($types) { $types[] = 'my_cpt'; return $types; });
filterfilterx/indexer/resolve_source

Parameters: $value, $source_key, $post_id

Filter the resolved index value for a given source key and post. Return a custom value to override default resolution.

add_filter('filterx/indexer/resolve_source', function($val, $key, $post_id) { if ($key === 'custom:brand') { return get_post_meta($post_id, 'brand', true); } return $val; }, 10, 3);

WooCommerce Integration Hooks

filterfilterx/rest/sample_post_data

Parameters: $data, $post

Enrich the sample post data used in Card Builder previews. The WooCommerce integration adds all WC fields here.

actionfilterx/grid/dynamic_data_init

Parameters: $dynamic_data

Register custom dynamic tag handlers. Pass a handler for your own {{namespace.field}} tags.

add_action('filterx/grid/dynamic_data_init', function($dd) { $dd->register_handler('brand', function($field, $post) { return get_post_meta($post->ID, 'brand', true); }); });