WordPress Integration

Three ways to add the Advlume script in WordPress (theme header, wp_head hook, header/footer plugin) and how to insert ad slot divs using Custom HTML blocks or widgets.

There is no dedicated Advlume WordPress plugin — the standard HTML snippet approach works in WordPress exactly as it does on any other site. This article covers the recommended methods for adding the Advlume script and ad slots in WordPress.

Method 1: Theme header (recommended)

The most reliable way to add the Advlume script to all pages is to paste it directly into your theme's header template.

  1. In your WordPress admin, go to Appearance → Theme Editor (or Appearance → Customize → Additional CSS is not the right place — you need Theme Editor).
  2. Open header.php (or the equivalent in your theme).
  3. Paste your <script> tag immediately before </head>:
    <script src="https://cdn.advlume.com/hb.js?site=YOUR-SITE-UUID" async></script>
    </head>
  4. Save the file.

Child theme note: If you are using a child theme, make the change in the child theme's header.php so it is not overwritten on theme updates.

Method 2: Hooks in functions.php

A cleaner approach that does not modify template files directly:

// Add to your theme's functions.php or a custom plugin
function advlume_enqueue_script() {
    echo '<script src="https://cdn.advlume.com/hb.js?site=YOUR-SITE-UUID" async></script>';
}
add_action('wp_head', 'advlume_enqueue_script', 1); // priority 1 = early

Method 3: A header/footer plugin

Plugins such as Insert Headers and Footers (WPCode) allow you to add scripts to <head> without editing theme files. Paste your <script> tag in the "Scripts in Header" field.

Adding ad unit divs in WordPress

Ad unit divs can be added in several ways:

  • Block editor (Gutenberg): Add a Custom HTML block where you want the ad to appear, then paste the slot snippet.
  • Classic editor: Switch to the Text (HTML) tab and paste the snippet at the desired position.
  • Widget areas: Add a Custom HTML widget to a sidebar or footer widget area, and paste the snippet.
  • Theme template files: Paste the snippet directly into the relevant PHP template (e.g. single.php for post pages, page.php for static pages).

Page caching considerations

WordPress caching plugins (WP Rocket, W3 Total Cache, etc.) may cache pages that include ad slot divs. This is fine — the ad slots are static HTML and will be populated dynamically by the Advlume wrapper on each page load. You do not need to exclude ad-containing pages from cache.

If you use a plugin that minifies or combines JavaScript, ensure the Advlume script is excluded from minification and combination (add hb.js to the exclusion list). Combining it with other scripts will break it.

Further reading

Last updated 2 months ago