Skip to content

Add custom scripts to your pages

Scripts Manager adds fields for code in the page <head> and near the end of <body>. You can set code sitewide, on a post type archive, or on an individual post, page, or term. It also lets you add body classes and turn off registered plugin assets on selected pages.

Before you start

  • You need an Administrator account on a site running Marketers Delight 6.0 or later.
  • Scripts Manager also requires WordPress 6.2 or later and PHP 7.4 or later.
  • Install and activate the Scripts Manager Drop-in.
  • Have the code or CSS class names you want to add ready.

Add sitewide code

  1. Go to Theme → Settings.
  2. Open Scripts.
  3. Enter any Body classes you want on every page.
  4. Enter code in Header Scripts for the page <head>, or in Footer Scripts for the end of the page.
  5. Select Save.
The Scripts panel on Edit Theme Settings with Body classes Header Scripts and Footer Scripts visible

These fields apply across the site.

FieldWhere its value appears
Body classesIn the page's <body> class list
Header ScriptsIn <head>, before the opening <body> tag
Footer ScriptsAfter <footer>, before the closing </body> tag

Add code to an archive or one page

For a post type archive, go to that post type's Settings screen and open Scripts. For a category or taxonomy archive, open its edit screen and find Scripts in its page settings. For an individual post or page, open Page Settings below the editor, then open Scripts. Each place has Body classes, Header Scripts, and Footer Scripts.

The Scripts Manager fields in Page Settings below a post editor

Set code or body classes for one post or page.

Page-specific scripts are added after the sitewide scripts; they do not replace them.

Turn off registered plugin assets

Scripts Optimization can turn off selected plugin scripts and styles on single posts and category or taxonomy archives. Its checkboxes appear only when a plugin has been registered with the md_filter_dequeue_scripts filter. If the section is absent, there are no registered choices to select.

Check the result

Open the affected page and inspect the relevant part of its HTML: <head>, the <body> classes, or the code before </body>. If your code is missing, check that you entered it in the intended sitewide or page-specific field and saved that screen. If Scripts Optimization is missing, check whether a plugin has been registered for it. If you use a caching plugin, clear its cache and reload.

Alex Mangini

Hi, I'm Alex! I started writing about web design and blogging at 13 years old, which turned into client work, which led to building my own software. 15 years later I'm still at it, and Marketers Delight is the epitome of my philosophy for building on the web.