Header and Footer

Header and Footer WordPress Plug-in lets you to insert whatever you need in to the head and the footer parts of each blog page and before and after the content of posts.

Its main purpose is to add various scripts to track the access to the blog (such as Google Analytics code, the verification code required by Google Webmasters Tools, the Facebook script for the like button or the Twitter one or the Google one for the Google Plus 1 button).

To insert something you have only to copy and paste the code supply by th service you want to use, there is no need to install 5 different plug-ins to integrate 5 external services. Clearly, if you aren’t able to copy and paste following the specific service examples or if they are unclear, keep on using a specific plug-in.

The code to be added on head section or footer section can contain PHP script part as well that will be executed.

Code can be added before or after the posts so you can easily “inject” the AdSense or other advertising network code.

Was it useful to you? Don’t miss a +1 or a like, thank you!

User guide

I create a PDF file with a more complete Header and Footer user guide: it is still valid but not all the features are explained.

Header and Footer Plugin User Guide (7080)

Download

Header and Footer is available on WordPress Plugin Directory at this URL

http://wordpress.org/extend/plugins/header-footer/

and if you find it useful, don’t forget to give it a vote.

Quick list of features

(so you can decide to install or not)

  1. Add a custom code (Javascript, CSS, HTML) to the head (<head>) section of every blog web page (eg. Google Analytics, Facebook, …)
  2. Add custom code to the head section only on the home page (eg. Google Webmaster verification code)
  3. Add custom code on the footer (before the </body>) of each blog web page (eg. late loading third party script)
  4. Codes can contain PHP parts that will be executed to add injection logic (minimum programming skills needed)
  5. Add custom code before and after each post content
  6. Add custom code before and after each page content
  7. Optionally add the Facebook og:image tag so a like on a post will be shown with the thumbnail or first post image
  8. Configurable default image for og:image Facebook tag for posts without an image
  9. Facebook og:type tag for home and generic web pages
  10. bbPress compatibility: the og:image tag will be filled with the first forum (see the FAQ)

The SEO options

The SEO (Search Engine Optimization) is a little off topic in Header and Footer plugin, anyway I added few options I think are missing on other SEO plugin. I’m not a SEO expert, so if you believe those options can lead to worse SEO performance, leave them disabled.

No-index for home sub pages

I want my home page indexed, of course, but I don’t want Google to add to its index the sub home pages, like:

http://www.myblog.com/page/2

since they are not content page and continuously changes as soon as I add a new article. Setting the option Header and Footer adds a meta tag with no-index indication on such pages.

No-index on search results

I don’t want Google to index search result pages. Your WordPress blog respond with a search results when you invoke it as:

http://www.myblog.com/?s=searchword

It’s not useful to have such URLs indexed since thay can be duplicated content. Setting the option Header and Footer adds ameta tag no-index on pages which responds “true” to the “is_search()” WordPress function.

Canonical tag on home page

Some plugin uses the home page URL (http://www.myblog.com/) with query string parameters (http://www.myblog.com/?a=value) to do special function. Sometime those URLs output the home page that can be indexed by Google (while we don’t want it to happen – it is duplicated content). Activating the canonical tag on home page, the meta tag “canonical” is added to the home page so the blog declares that the official URL for http://www.myblog.com/?a=value is http://www.myblog.com/ and Google considers only the latter.

F.A.Q.

About bbPress and og:image Facebook tag: where have I to add the image?

Creating a forum is like creating a post. Add an image from the forum editing panel (even if without inserting it on the forum description) and that image will be used.

Does the plug-in generate the other og: Facebook tags (not mentioned above)?

Actually not.

What image is used for the og:image tag on home page?

If a default image is specified, that one.

I added PHP but it will be printed out than executed.

PHP must be add this way: <?php some code ?>. It can spans multiple lines.

Usage

All posts about Header and Footer can be found under the tag “header footer“.

It’s so simple that this paragraph is not really useful, but… here a screen shot of the configuration panel with values I’m using in a my blog.

header-footer-1

There are themes which fo not have the “wp_footer” call, or have the footer crypted: check the source of generated pages to see if the code you configured is injected or not. Other plugins that add such kind of codes in the footer may have the same problem!

The image below is the source of an internal page of a my blog: the Analytics code is there.

header-footer-2

Using PHP code

PHP code can be used on footer and header configuration to add specific logic and control what will be inserted. The classical example is to avoid Google Analytics code while the admin is logged in.

Here an example directly from my blog:

<? if (!is_user_logged_in()) { ?>
<script type="text/javascript">
...GOOGLE ANALYTICS CODE...
</script>
<? } ?>

The surrounding

<? if (!is_user_logged_in()) { ?>

and

<? } ?>

let the code to be added only when a user is not logged in. Clearly this logic is good only for blog which have only an administrator, not the ones having lot of registered people that has to be tracked.

Versions and more

Everithing I wrote about Header and Footer plugin can be found under the tag “header footer“.

by Stefano Lissa

33 thoughts on “Header and Footer

  1. Pingback: WordPressプラグイン | カメラタイムBlog

  2. Pingback: Zehn nützliche Plugins für jeden WordPress Blog • blog, jetpack, plugins, seo, subscriptions, tipps, wordpress • Der LeuMund.ch

  3. Yang

    Hi, nice plugin. I’m using this to add a footer to my post content. I found that these are only showing up on the website, and not in RSS feeds – any way this could support working on RSS feeds? Thanks in advance.

    Reply
  4. Steve Hong

    It’s awesome that this plugin recognizes PHP. I’m using it for the same thing you recommend in your examples: hiding Analytics from logged in users.

    The plugin doesn’t work for adding CSS and JS, though, because my custom code is added into the head before other theme styles and scripts are included, ruining the hierarchies and dependencies. You changed it to a high priority in version 1.1.3, for reasons I understand, but this makes it less useful for a wide variety of other cases. I modified the code in plugin.php myself to decrease the priority (changed from 1 to 10): “add_action(‘wp_head’, ‘hefo_wp_head’, 10);”. This makes the custom code appear at the end of the head, after other CSS/JS.

    I’d like to recommend you offer an option to set the priority in the options page. A lot of people could use this for sitewide custom CSS/JS if you made this change. Thanks again for the plugin.

    Reply
  5. Easy WP SEO

    Thanks a million for your plugin! This is so much better than editing themes and having to copy custom code into templates when you change them. I was going to write my own plugin for this but decided to do a search first. This saved me a ton of time! :D

    Reply
  6. Barry Lo

    This plugin is a very very simple but yet extremely useful. Adding scripts and html codes thru it allow you to change theme freely. I like it very much.

    Reply
  7. Pingback: Flash Web Themes 101 | Find Out as Much as You Can

  8. Pingback: wordpress plugins « floydius

  9. JUHLi SELBy

    Thank you for sharing this info! I’m a do-it-yourself-er and was trying to figure out how to add Google Analytics to my WordPress site. I appreciate it.

    P.S. Which comment system/plug-in is this? Cool that you can upload a pic!

    Reply
  10. Pingback: Flash Web Themes 101 – Find Out Just As Much As You Could

  11. Pingback: :: Have You Done Your Research Correctly? – Find Out More About Flash Web Templates

  12. Pingback: Flash Themes Common Myths Which Were Confirmed To Be Incorrect | Web Design and Development Company

  13. Pingback: Flash Web Templates Myths Which Are Proven To Be False | Blogging Syndicate Review - Desmond Ong

  14. Pingback: Flash Web Themes 101 - Understand Just As Much As You Could : marketing marbles

  15. Chris

    Love your plugin, but I have one problem. I’m using the old Google Analytics tracking code because I need to also use a script to dynamically set up cross-domain link support. The script looks through the page and finds any links pointing to any of the domains I’m doing cross domain tracking on and then wraps them in the necessary code. The problem is that it is not seeing the links in my header because they are generated by JS and that js is somehow getting loaded after the code inserted by your plugin.
    How can I remedy this? Any thoughts?
    Check out the source http://robotmuaythai.com

    Reply
    1. Steve Hong

      Chris, you have the same problem as I did. Your custom scripts are written into the head before other theme script dependencies. See my other comment for a fix you can make to the plugin.

      Reply
  16. Pingback: Flash Web Themes Misguided Beliefs That Were Proven To Be False :Chris and Eddie in London NW1

  17. Evan

    Great plug-in. I didn’t know you could use PHP with it, that’s awesome!

    Have you ever thought about adding some simple hotkey functionality to it? (ex: ctrl-s saves)

    I primarily use this for custom CSS as it’s easier and quicker than updating the style.css or child theme files.

    Reply
  18. Pingback: Cloudflare – Potentially Mindblowing e-Commerce CDN Solution

  19. Pingback: My Top Ten Plugins – Plugins Proven to Pimp Up Your Pride & Joy | Authopublisher

  20. Pingback: WordPress Themes – Instalação E Administração Parte12 | Webmaster.pt - Marketocracia Digital

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>