A Marketers Delight drop-in for adding custom code to the <head> and the end of the <body>, sitewide or on specific posts, archives and terms. It can also add body classes to individual pages, and turn off plugin scripts and styles on pages that don't need them.
- Header scripts, printed in
<head> - Footer scripts, printed before
</body> - Sitewide scripts, plus scripts for single posts and pages, post type archives and the blog page, and category and taxonomy archives. Page-specific scripts are added after the sitewide ones.
- Custom body classes, sitewide or on individual posts, pages and terms
- Scripts Optimization: turn off selected plugin scripts and styles on single posts and on category and taxonomy archives. The list of plugins comes from the
md_filter_dequeue_scriptsfilter, and the option only shows when something is registered. - Prints the Google Analytics (gtag.js) tag when a Google Analytics ID is set in MD's integration settings
Sitewide (MD settings dashboard → Scripts):
- Body classes
- Header Scripts
- Footer Scripts
Post type archives: the same three fields in each post type's settings, for its archive page (and the blog page for posts).
Per page: in the Page Settings box on posts and pages, and on category and taxonomy term screens:
- Body classes
- Header Scripts
- Footer Scripts
- Scripts Optimization: checkboxes for each registered plugin (only shows when a plugin is registered)
md_filter_dequeue_scripts: register plugins whose assets can be turned off per page. Return an array keyed by an ID, where each item holdslabel, and optionallyscriptsandstyles(arrays of registered handles).
add_filter( 'md_filter_dequeue_scripts', function( $plugins ) {
$plugins['contact-form'] = array(
'label' => 'Contact Form',
'scripts' => array( 'contact-form-js' ),
'styles' => array( 'contact-form-css' )
);
return $plugins;
} );- Marketers Delight 6.0 or later
- WordPress 6.2 or later
- PHP 7.4 or later
- Download the latest
scripts-x.y.z.zipfrom the Releases page. - In WordPress, go to MD's Drop-ins screen, click Add new, and upload the zip.
- Activate Scripts Manager, then add your scripts in MD's settings or on any post.
Don't use Code → Download ZIP. That zip includes development files and a folder name that MD won't recognize.
GPL-2.0-or-later. See LICENSE.