Title: External Header Footer
Author: Sully Syed
Published: <strong>January 2, 2015</strong>
Last modified: December 9, 2018

---

Search plugins

This plugin **hasn’t been tested with the latest 3 major releases of WordPress**.
It may no longer be maintained or supported and may have compatibility issues when
used with more recent versions of WordPress.

![](https://s.w.org/plugins/geopattern-icon/external-header-footer.svg)

# External Header Footer

 By [Sully Syed](https://profiles.wordpress.org/yllus/)

[Download](https://downloads.wordpress.org/plugin/external-header-footer.zip)

 * [Details](https://wordpress.org/plugins/external-header-footer/#description)
 * [Reviews](https://wordpress.org/plugins/external-header-footer/#reviews)
 *  [Installation](https://wordpress.org/plugins/external-header-footer/#installation)
 * [Development](https://wordpress.org/plugins/external-header-footer/#developers)

 [Support](https://wordpress.org/support/plugin/external-header-footer/)

## Description

**External Header Footer** is a simple WordPress plug-in that exposes that site’s
header and footer over HTTP as URLs whose content can then be consumed.

How is this useful? Let’s say you’ve got a WordPress website at your **www** subdomain,
and a forum for your community of users at a **forums** subdomain. In many cases,
you’ll want to keep the header, footer and basic styling (link, text, background
colours) of both sites identical.

That’s the cue to use **External Header Footer**: Once this plug-in is enabled on**
www**, run a scheduled task on your **forums** subdomain to retrieve and locally
store (write to a file, or to memory) the header and footer to be displayed on that
site every day/hour/week. Now with minimal effort you can be assured that both sites
will maintain a consistent look and feel.

## Installation

 1. Enable **External Header Footer** within the **Plugins** > **Installed Plugins**
    interface.
 2. Head over next to the settings page for the plug-in at **Settings** > **External
    Header Footer**.
 3. Check the **Expose Header and Footer** checkbox and click the **Save Changes** 
    button.
 4. The settings page should return with a message indicating your changes have been
    saved. The page will also list three URLs that are now ready for viewing and use.
    The **Demo Page URL** provides a demonstration of what some sample content will
    look like when the header and footer are read in and then displayed at the top 
    and bottom of that page – check out the (very straightforward) source code of test-
    page.php to understand how to use this plug-in on your external website(s).
 5. On the WordPress side of things, your work is done. To finish up, set up your external
    website(s) to retrieve from **Header URL** and **Footer URL**, sandwiching the 
    actual content of the site in between them.

## FAQ

  Consuming an External Header and Footer to display on your WordPress Site

 1.  If not already done, enable **External Header Footer** within the **Plugins** 
     > **Installed Plugins** interface.
 2.  Head over next to the settings page for the plug-in at **Settings** > **External
     Header Footer**.
 3.  Enter a valid URL into the **External Header URL** and **External Footer URL**
     fields (or leave one or the other blank if you only need one of the two).
 4.  Verify that the **Cache Header/Footer For** setting contains an appopriate value
     that is denominated in minutes.
 5.  Click the **Save Changes** button.
 6.  The settings page should return with a message indicating your changes have been
     saved. Next, click on the URL for the **External Demo Page URL** to see a demonstration
     of what a page wrapped with the specified external header and footer would appear
     like.
 7.  To display the external header on a page, simply call the following function:
 8.      ```
         ehf_output_external_header();
         ```
     
 9.  Similarly, call the following function to output the external footer to a page:
 10.     ```
         ehf_output_external_footer();
         ```
     
 11. Note: Through use of the best caching system available on your WordPress site,
     the HTML markup for the header and footer will be saved to your local WordPress
     website, and only re-retreived when the cache expiry value is reached. Of course,
     any CSS, JavaScript or image assets on the external site will be retrieved from
     that site by your site visitors.

  Advanced Usage

Sometimes the contents of your header or footer will cause conflicts or problems
if displayed on an external website: Let’s say you’re using the popular **Google
Analytics for WordPress** plug-in on your WordPress site, but your external website
has its own Google Analytics code, and you don’t want to get the two mixed together.
No problem – but it will take a little bit of code.

Two new WordPress Actions are included as part of this plug-in; both allow you to
run your own code immediately before the external header and footer are displayed
at their new individual URLs:

    ```
      external_header_footer_pre_header
      external_header_footer_pre_footer
    ```

Let’s say you need to stop **Google Analytics for WordPress** from In your theme’s
functions.php file, write a function that removes the addition of JavaScript code
for Google Analytics by removing the action that adds to your site’s header. Then
simply call hook your function to the **external_header_footer_pre_header** action.
Here’s an example of that code:

    ```
     function remove_ga_from_external_header() {
       // Remove the addition of AdSense JavaScript code from the header.
       remove_action( 'wp_head', array( 'GA_Filter', 'spool_adsense' ), 1 );

       // Remove the addition of Google Analytics JavaScript code from the header.
       remove_action( 'wp_head', array( 'GA_Filter', 'spool_analytics' ), 2 );
     }

     // Call the function remove_ga_from_external_header() immediately before the external header is displayed (at its individual URL).
     add_action('external_header_footer_pre_header', 'remove_ga_from_external_header');
    ```

Use the **external_header_footer_pre_footer** and the same technique – use of remove_action
or remove_filter – to ensure only the code you want to go out as part of the footer
is output.

  Tips & Tricks

 * Avoid having the header and footer retrieved every time your external website
   displays a page. Instead, see if you can schedule a task to retrieve the header
   and footer occasionally (say, once an hour) and save it to the external website’s
   diskspace. Then output the contents of those files when pages are requested on
   the external website.
 * Ensure that the URLs in your header and footer are absolute to ensure that they
   point to pages that exist when they’re being displayed on an external website.
   For example, if you’ve got the following URL coded into your header to point 
   to your “About Us” page:
 *     ```
        <a href="/about-us/">About Us</a>
       ```
   
 * You can use the standard WordPress function home_url() to ensure that the URL
   is output in absolute form:
 *     ```
        <a href="<?php home_url('/about-us/'); ?>">About Us</a>
       ```
   
 * For more information, check out the WordPress Codex entry for home_url at https://
   codex.wordpress.org/Function_Reference/home_url .
 * Need to clear the cache of an external header/footer immediately? No problem –
   clicking the **Save Changes** button on the settings page for this plug-in do
   exactly that.

## Reviews

![](https://secure.gravatar.com/avatar/1795677d27d7208b6092e62c88ee751fdae588000d718dfc6e88224c79dfd390?
s=60&d=retro&r=g)

### 󠀁[great but could be improved](https://wordpress.org/support/topic/great-but-could-be-improved-1/)󠁿

 [m.hallor](https://profiles.wordpress.org/mhallor/) September 3, 2016

works well but I would like an option to not only force absolute URLs, but also 
force target=”_parent”

 [ Read all 2 reviews ](https://wordpress.org/support/plugin/external-header-footer/reviews/)

## Contributors & Developers

“External Header Footer” is open source software. The following people have contributed
to this plugin.

Contributors

 *   [ Sully Syed ](https://profiles.wordpress.org/yllus/)

[Translate “External Header Footer” into your language.](https://translate.wordpress.org/projects/wp-plugins/external-header-footer)

### Interested in development?

[Browse the code](https://plugins.trac.wordpress.org/browser/external-header-footer/),
check out the [SVN repository](https://plugins.svn.wordpress.org/external-header-footer/),
or subscribe to the [development log](https://plugins.trac.wordpress.org/log/external-header-footer/)
by [RSS](https://plugins.trac.wordpress.org/log/external-header-footer/?limit=100&mode=stop_on_copy&format=rss).

## Changelog

#### 1.0.2

 * Verified compatibility with WordPress v5.0.0. Cleaned up readme.txt line breaks.

#### 1.0.1

 * Adds a “Force Use Of Absolute URLs” option that automatically rewrites URLs that
   are relative to the site’s root to be absolute URLs instead.
 * Adds a “Force Use Of HTTPS” option that automatically rewrites all URLs pointing
   to your WordPress site’s domain in your header and footer to a HTTPS version 
   of those links instead.

#### 1.0

 * Initial release; tested compatibility with WordPress v3.9.2.

## Meta

 *  Version **1.0.1**
 *  Last updated **7 years ago**
 *  Active installations **60+**
 *  WordPress version ** 3.5.2 or higher **
 *  Tested up to **5.0.0**
 *  [Advanced View](https://wordpress.org/plugins/external-header-footer/advanced/)

## Ratings

 4.5 out of 5 stars.

 *  [  1 5-star review     ](https://wordpress.org/support/plugin/external-header-footer/reviews/?filter=5)
 *  [  1 4-star review     ](https://wordpress.org/support/plugin/external-header-footer/reviews/?filter=4)
 *  [  0 3-star reviews     ](https://wordpress.org/support/plugin/external-header-footer/reviews/?filter=3)
 *  [  0 2-star reviews     ](https://wordpress.org/support/plugin/external-header-footer/reviews/?filter=2)
 *  [  0 1-star reviews     ](https://wordpress.org/support/plugin/external-header-footer/reviews/?filter=1)

[Your review](https://wordpress.org/support/plugin/external-header-footer/reviews/#new-post)

[See all reviews](https://wordpress.org/support/plugin/external-header-footer/reviews/)

## Contributors

 *   [ Sully Syed ](https://profiles.wordpress.org/yllus/)

## Support

Got something to say? Need help?

 [View support forum](https://wordpress.org/support/plugin/external-header-footer/)

## Donate

Would you like to support the advancement of this plugin?

 [ Donate to this plugin ](https://github.com/yllus/external-header-footer)