Third Party Scripts
Many WordPress sites require external tracking, analytics, or functionality scripts. This page explains how to add third-party scripts to LumberMill.
ACF Option Pages (recommended)
Section titled “ACF Option Pages (recommended)”LumberMill includes a built-in ThirdPartyScriptsHook that reads script snippets from ACF option page fields and outputs them at the correct positions. This lets content editors manage scripts without touching code.
The three fields on the Theme Settings options page are:
| Field key | Output location |
|---|---|
theme_settings_third_party_scripts_head | <head> via wp_head |
theme_settings_third_party_scripts_body_open | After <body> via wp_body_open |
theme_settings_third_party_scripts_body_close | Before </body> via wp_footer |
Paste the full script tag (e.g. Google Tag Manager, Meta Pixel) into the relevant field and it will be output automatically.
Custom Hook
Section titled “Custom Hook”For scripts that need to be added in code, create a method in a hook class and attach it to the appropriate WordPress action.
public function register(): void{ add_action('wp_head', [$this, 'addGtm']);}
public function addGtm(): void{ echo '<script>/* GTM snippet */</script>';}Available actions:
wp_head— insert in<head>wp_body_open— insert after<body>tagwp_footer— insert before closing</body>
Dynamic values
Section titled “Dynamic values”public function addInlineScript(): void{ $value = get_some_option(); printf('<script>var myVar = "%s";</script>', esc_js($value));}Always escape dynamic values with esc_js() for JavaScript strings.
External Scripts
Section titled “External Scripts”External scripts can be registered via the config/assets.php file.

