# WordPress

> Add the Taggor snippet to a WordPress site without a plugin, and place a component in a block.

> Esta página ainda não tem tradução para o português; este é o texto em inglês. (This page is not translated yet: the English text follows.)

WordPress is the platform most agencies start with. This guide is for a self-hosted WordPress (6.3 or
newer) where you can edit the theme or add code. There is no Taggor plugin yet.

## Install the snippet once

Add this to your theme's `functions.php` (a child theme, so an update does not remove it) or to a small
plugin of your own:

```php title="functions.php"
add_action( 'wp_enqueue_scripts', function () {
	wp_enqueue_script( 'taggor', 'https://cdn.taggorcdn.com/s/<site-key>.js', array(), null, array( 'strategy' => 'async', 'in_footer' => true ) );
} );
```

`wp_enqueue_script` with the `async` strategy and `in_footer` loads the script without blocking the page
and is available from WordPress 6.3 (WordPress reference, `https://developer.wordpress.org/reference/functions/wp_enqueue_script/`,
read 2026-11-09). The `null` version keeps WordPress from adding `?ver=` to the address.

## Place the component

In the block editor, add a **Custom HTML** block and write the component's tag:

```html title="index.html"
<contact-form heading="Get in touch"></contact-form>
```

## Limits

- The Custom HTML block keeps a script tag only for users with the `unfiltered_html` capability; that does not
  matter here, because the script comes from `functions.php` and the block holds only the tag. On a
  multisite, only the Super Admin has the capability (Unfiltered MU, `https://wordpress.org/plugins/unfiltered-mu`, read 2026-11-09).
- On WordPress.com, code needs a plan that allows plugins; free sites do not accept it
  (WordPress.com, Code, `https://wordpress.com/support/code/`, read 2026-11-09).
- Page caches and optimizers that combine or delay scripts can change when the snippet runs. The loader
  waits for the page to finish parsing before it loads anything, so it does not break the page's own
  import map.

## Common problems

- **The component does not appear.** Open the page source and look for the snippet's script tag. A cache
  plugin may serve the old page: clear it. The tag in the block must be written exactly as the component
  names it, with a hyphen.
- **A block shows the tag as text.** The tag was typed in a paragraph block, not in Custom HTML.

## How we checked

The compatibility matrix runs the four test components on WordPress 7.1.4 in Docker: in a Custom HTML
block with the Twenty Twenty-Five and Twenty Twenty-Four themes, and in an Elementor HTML widget, in
Chromium, Firefox and WebKit and two mobile emulations. It also checks the case where WordPress prints its
own import map after the snippet. Not checked: the PHP snippet itself was checked as text and not run, and
no WordPress.com site was used.
