> ## Documentation Index
> Fetch the complete documentation index at: https://docs.polyembed.io/llms.txt
> Use this file to discover all available pages before exploring further.

# WordPress

> Install the PolyEmbed plugin and add the [polyembed] shortcode to your posts or single-post template.

The PolyEmbed WordPress plugin adds a `[polyembed]` shortcode. It fills in the post title for you, builds the iframe, and includes the resize and collapse script.

## Install the plugin

**1. Get the plugin**

Email [contact@polyembed.io](mailto:contact@polyembed.io) for the current `polyembed` plugin ZIP.

**2. Upload it**

In WordPress, go to **Plugins > Add New > Upload Plugin**, choose the ZIP, and click **Install Now**.

**3. Activate it**

Click **Activate**. The plugin is called **PolyEmbed Widget** in your plugin list.

## Add the shortcode

Copy the shortcode from the **WordPress** tab on your widget page:

```text Shortcode theme={null}
[polyembed widget_id="YOUR_WIDGET_ID"]
```

Then add it where the widget should appear:

**In one post**

In the block editor, add a **Shortcode** block and paste the shortcode.

**In every post**

Add the shortcode to your theme's single-post template so every article gets a widget. In a block theme, edit the **Single Posts** template in **Appearance > Editor** and add a **Shortcode** block. In a classic theme, call it from `single.php`:

```php single.php theme={null}
<?php echo do_shortcode('[polyembed widget_id="YOUR_WIDGET_ID"]'); ?>
```

## Add keywords for tighter matches

The shortcode uses the post title automatically. Add `keywords` to improve matching:

```text theme={null}
[polyembed widget_id="YOUR_WIDGET_ID" keywords="federal reserve,interest rates"]
```

To use each post's tags as keywords in a template:

```php single.php theme={null}
<?php
$tags = wp_get_post_tags(get_the_ID(), ['fields' => 'names']);
$keywords = implode(',', array_slice($tags, 0, 4));
echo do_shortcode(sprintf(
  '[polyembed widget_id="YOUR_WIDGET_ID" keywords="%s"]',
  esc_attr($keywords)
));
?>
```

See the [shortcode reference](https://docs.polyembed.io/reference/shortcode.md) for every attribute.

## Signed snippets

If your widget page shows a shortcode with `d`, `kv` and `sig` attributes, copy it exactly. Those attributes sign the snippet to your domain. If you rotate the embed key, replace the shortcode everywhere you use it. See [Embed security](https://docs.polyembed.io/publishers/embed-security.md).

## Caching and security plugins

* Page caches are fine: the widget does its matching inside the iframe on every load.
* If a security plugin sets a `Content-Security-Policy`, allow `frame-src https://iframe.polyembed.io`.
* If an optimization plugin rewrites iframes (for example to lazy-load them), make sure it keeps the `referrerpolicy` attribute and the script that follows the iframe.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.