> For the complete documentation index, see [llms.txt](https://ce-docs.keywordrush.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ce-docs.keywordrush.com/customization/fordevelopers.md).

# For developers

### Custom templates

You can add to your theme unique templates for the Content Egg plugin.

{% content-ref url="/pages/LZHKpJZVvdSvto4fdt91" %}
[How to create a custom template](https://ce-docs.keywordrush.com/custom-templates/how-to-create-a-custom-template.md)
{% endcontent-ref %}

### Front search customization

{% content-ref url="/pages/-M4jeTxp2nFL5Neqyd-k" %}
[Frontend Search](https://ce-docs.keywordrush.com/frontend/frontendsearch.md)
{% endcontent-ref %}

### REST API

{% content-ref url="/pages/N7pkUlqzmMuNxPnLZzvK" %}
[REST API](https://ce-docs.keywordrush.com/customization/rest-api.md)
{% endcontent-ref %}

### Accessing and Modifying Data with Hooks

The Content Egg plugin provides several WordPress hooks to allow developers to interact with the data lifecycle. Below is a detailed reference for working with Content Egg data and customizing its behavior.

#### `content_egg_save_data`

```php
add_action('content_egg_save_data', 'my_function', 13, 4);
```

**Description**:\
Triggered after saving or updating Content Egg data for a post. Useful for intercepting or modifying saved data per module.

**Parameters**:

* `$data` *(array)* — Raw data array saved by the module.
* `$module_id` *(string)* — ID of the Content Egg module (e.g., `amazon`, `ebay`).
* `$post_id` *(int)* — WordPress Post ID.
* `$is_last_iteration` *(bool)* — Whether this is the final module being processed for this post.

#### `cegg_autoblog_post_create`

```php
add_action('cegg_autoblog_post_create', 'my_function', 10, 1);
```

**Description**:\
Triggered right after a new post is created by the Auto Blog functionality.

**Parameters**:

* `$post_id` *(int)* — ID of the newly created post.

### Accessing Stored Module Data

#### Raw Module Data (Unprocessed)

Content Egg stores module data in standard WordPress custom fields. To retrieve raw data:

```php
get_post_meta($post_id, '_cegg_data_' . $module_id, true);
```

* Returns an **array** of module results for the given post and module.
* Useful for debugging or low-level manipulation.

#### Processed View Data (Recommended for Display)

To get data already processed and formatted for display (e.g., as shown in templates):

```php
\ContentEgg\application\components\ContentManager::getViewData($module_id, $post_id);
```

* Returns **render-ready** data.
* Ideal for use in custom themes or shortcodes.

### Filters for Customization

#### Filter: Module Templates

```php
add_filter('content_egg_module_templates', 'my_filter_function', 10, 2);
```

* **$templates** *(array)* — List of available templates.
* **$module\_title** *(string)* — Human-readable title of the module (e.g., "Amazon", "eBay").

Use this to modify or restrict which templates are available for a module.

#### Filter: Block Templates

```php
add_filter('content_egg_block_templates', 'my_filter_function');
```

Customize the available **block templates** across modules.

#### Filter: Enable/Disable Modules

```php
add_filter('content_egg_modules', 'my_filter_function');
```

Dynamically enable or disable Content Egg modules.

{% hint style="warning" %}
**Important:** Use with caution. If you're disabling default features in your theme or plugin, **always inform users** clearly about the changes and rationale.
{% endhint %}

#### Filter: Available Modules per Post

```php
add_filter('content_egg_metabox_modules', 'my_filter_function', 10, 2);
```

* **$module\_ids** *(array)* — IDs of the modules offered on the post being edited.
* **$post\_id** *(int)* — ID of that post. Available since Content Egg 21.1.0. The classic metabox calls the filter with one argument only, so always give this parameter a default value (`$post_id = 0`), otherwise the callback fails there.

Controls which modules can be selected while editing a post. Both the classic metabox and the Products sidebar go through this filter, so a module you remove here is unavailable in either interface.

Nothing is disabled: unlike `content_egg_modules`, the module keeps its settings, keeps updating its data, and keeps rendering on the frontend. It is only absent from the module lists in the editor.

{% hint style="warning" %}
The module list is requested separately for each family — products, coupons, images and videos — so the filter runs once per family and receives only that family's IDs. Remove the IDs you don't want rather than returning a fixed allowlist, or the other families end up empty.
{% endhint %}

A ready-made example that limits modules per post type is in [Useful code snippets](https://ce-docs.keywordrush.com/customization/useful-code-snippets.md#available-modules-per-post-type).

#### Filter: Tracked Items (price history and price alerts)

```php
add_filter('cegg_price_tracked_items', 'my_filter_function', 10, 4);
```

* **$items** *(array)* — The items of one module, under their keys.
* **$module\_id** *(string)* — The module ID.
* **$post\_id** *(int)* — The post being saved.
* **$context** *(string)* — `current` for the items being saved, `previous` for the items stored before this save.

Content Egg records price history, sends price alerts and back-in-stock alerts for the items of a save. This filter lets you change that list, for example to add a virtual offer that your code builds from several stored items (a set of products with one summed price). Return the array unchanged when you have nothing to add.

Set `_cegg_history_only` to `true` on an item to record its history without any alert and without a Price drops entry. Use it for the stored items a virtual offer is built from.

Items you add are tracked as they are. Content Egg does not restate their history when a shop's VAT setting changes, so rebuild it yourself.

#### Filter: Price Drops Post Lookup

```php
add_filter('cegg_price_drop_post_for', 'my_filter_function', 10, 4);
```

* **$post\_id** *(int)* — The post Content Egg found for the offer, or 0.
* **$unique\_id** *(string)* — The offer ID.
* **$module\_id** *(string)* — The module ID.
* **$exclude\_post** *(int)* — A post that must not be returned, or 0.

Price drops finds the post of an offer in the product index, which holds stored items only. Use this filter to return the post of a virtual offer that is tracked through `cegg_price_tracked_items`. Return `$post_id` unchanged for everything else.
