---
title: "Filter- and action hooks"
description: "All filters of WXP Opening Times: status, templates, stylesheet, structured data and holiday providers, with their arguments and examples."
url: "https://wxpplugins.com/docs/wxp-opening-times-hooks/"
updated: "2026-10-30"
category: WXP Opening Times / For developers
---

# Filter- and action hooks

WXP Opening Times offers filters to change the status it reports, the templates, the stylesheet, the structured data and the holiday calendars. It has no action hooks. All names start with `wxp_opening_times_`.

## How to use a hook

A **filter** receives a value, can change it and must return it. An **action** tells you that something happened, and returns nothing. Add your code to the `functions.php` of your child theme, or to a small plugin of your own. The last number of `add_filter()` and `add_action()` is the number of arguments your function receives; ask for as many as you need.

```
add_filter( 'hook_name', function ( $value, $extra ) {
	// Change $value here.
	return $value;
}, 10, 2 );

add_action( 'hook_name', function ( $first, $second ) {
	// React here.
}, 10, 2 );
```

## Overview

| Hook | Type | What it does |
| --- | --- | --- |
| `wxp_opening_times_status` | Filter | Changes the status returned by `wxp_opening_times_get_status()` and `wxp_opening_times_is_open()`. |
| `wxp_opening_times_holidays` | Filter | Changes the holiday providers, for example to add Islamic or Jewish holidays. The bundled secular and Christian providers come first. |
| `wxp_opening_times_schema` | Filter | Changes the structured data (JSON-LD) of a schedule, for example to set a more specific type such as Restaurant or to add an address. Also used by `wxp_opening_times_get_schema()`. |
| `wxp_opening_times_schema_days` | Filter | Changes how many days ahead the exceptions (periods and holidays) are added to the structured data. |
| `wxp_opening_times_template_context` | Filter | Changes the data that is passed to a Twig template, so you can use extra values in your own template. |
| `wxp_opening_times_template_paths` | Filter | Changes the folders where templates are looked for, in lookup order. The folders of your (child) theme come before the templates folder of the plugin. |
| `wxp_opening_times_twig_cache` | Filter | Sets a folder for the compiled templates. Caching is off by default, so no files are written. |
| `wxp_opening_times_load_css` | Filter | Decides whether the plugin loads its own stylesheet. Return `false` to use your own CSS. |

## Status and holidays

### `wxp_opening_times_status`

**Filter.** Changes the status returned by `wxp_opening_times_get_status()` and `wxp_opening_times_is_open()`.

| Argument | Type | Description |
| --- | --- | --- |
| `$status` | array | `open` (bool), `closes_at`, `opens_at`, `next_change` (Unix times or null) and `schedule` (the id). |
| `$schedule` | Schedule | The schedule that was checked. |
| `$moment` | DateTimeImmutable | The moment that was checked, in the time zone of the site. |

**Return:** the status array.

### `wxp_opening_times_holidays`

**Filter.** Changes the holiday providers, for example to add Islamic or Jewish holidays. The bundled secular and Christian providers come first.

| Argument | Type | Description |
| --- | --- | --- |
| `$providers` | array | Provider objects that implement the `HolidayProviderInterface` of the plugin. |

**Return:** the list of providers. Add your own provider object to the list.

## Structured data (schema.org)

### `wxp_opening_times_schema`

**Filter.** Changes the structured data (JSON-LD) of a schedule, for example to set a more specific type such as Restaurant or to add an address. Also used by `wxp_opening_times_get_schema()`.

| Argument | Type | Description |
| --- | --- | --- |
| `$data` | array | The JSON-LD data. |
| `$schedule` | Schedule | The schedule. |

**Return:** the data. Return an empty value to print nothing.

```
add_filter( 'wxp_opening_times_schema', function ( array $data ) {
	$data['@type']   = 'Restaurant';
	$data['address'] = 'Main Street 1, Amsterdam';
	return $data;
} );
```

### `wxp_opening_times_schema_days`

**Filter.** Changes how many days ahead the exceptions (periods and holidays) are added to the structured data.

| Argument | Type | Description |
| --- | --- | --- |
| `$days` | int | Number of days, `365` by default. The minimum is 1. |
| `$schedule` | Schedule | The schedule. |

**Return:** the number of days.

## Templates and stylesheet

### `wxp_opening_times_template_context`

**Filter.** Changes the data that is passed to a Twig template, so you can use extra values in your own template.

| Argument | Type | Description |
| --- | --- | --- |
| `$context` | array | The template data. |
| `$name` | string | The name of the template. |
| `$schedule` | Schedule | The schedule that is shown. |

**Return:** the template data.

### `wxp_opening_times_template_paths`

**Filter.** Changes the folders where templates are looked for, in lookup order. The folders of your (child) theme come before the templates folder of the plugin.

| Argument | Type | Description |
| --- | --- | --- |
| `$paths` | string\[\] | Folders. |

**Return:** the list of folders.

```
add_filter( 'wxp_opening_times_template_paths', function ( array $paths ) {
	array_unshift( $paths, WP_CONTENT_DIR . '/my-opening-times-templates' );
	return $paths;
} );
```

### `wxp_opening_times_twig_cache`

**Filter.** Sets a folder for the compiled templates. Caching is off by default, so no files are written.

| Argument | Type | Description |
| --- | --- | --- |
| `$cache` | string\|false | A folder, or `false` (default). |

**Return:** a folder, or `false`.

### `wxp_opening_times_load_css`

**Filter.** Decides whether the plugin loads its own stylesheet. Return `false` to use your own CSS.

| Argument | Type | Description |
| --- | --- | --- |
| `$load` | bool | `true` by default. |

**Return:** `true` or `false`.

```
add_filter( 'wxp_opening_times_load_css', '__return_false' );
```

## Good to know

- **Helper functions:** to read the opening times from your own code, see the functions `wxp_opening_times_is_open()`, `wxp_opening_times_get_status()`, `wxp_opening_times_get_day()`, `wxp_opening_times_get_weekly()`, `wxp_opening_times_get_holidays()`, `wxp_opening_times_get_schedules()` and `wxp_opening_times_get_schema()`.
- **Priority:** add your filters from your theme or from a plugin. They run every time the value is needed, so keep them light.
