Introducing The P2 Header Ad Plugin

- by

P2 Header Ad IconI always loved Automattic’s P2 theme: it’s one of the most innovative ideas for blogging I could find. I’m using it on several of my notebook websites, including this one. I’ve been tweaking P2 for quite some time, and one thing I wanted to do is display an advert inside the P2 header.

As you may know, P2 doesn’t like child themes very much, so I wrote a future proof solution as this handy plugin.

P2 Header Ad let’s you display an advert of your choice inside the header. And when the theme is updated, your advert stays in place. Neat, huh?

How it works

Simply install the plugin and activate it the usual way. Make sure you have the P2 Theme activated, otherwise the plugin will show an error message. You’ll find a new option under Appearance – P2 Header Ad. Here’s what it looks like:

P2 Header Ad - Admin Options
P2 Header Ad – Admin Options
And here's what the dummy advert looks like on the front page
And here’s what the dummy advert looks like on the front page

Adding your own Code Snipptes

To demo what an advert will look like, I’ve added some sample code. You can activate it via the “Use Sample Data” button. Use your own code by adding it to the box and hit “Save Changes”. The plugin will display a preview underneath the box. Check out the front page to see what it looks like.

You can embed standard HTML code, but not PHP code at this time. Out of the box the CSS will position your 468×60 pixel ad nicely inside the top header. Other sizes will need to be adjusted.

Tweaking the CSS

I’m using a custom ID called “p2HeaderAd” which is appended to your code. Feel free to override this. If you’d like to tweak the plugin’s CSS, have a look for a file called p2-header-ad-styles.css.


The plugin is available in several other languages. These will show up automatically if you set your WordPress installation to another language as explained here.

If you would like to help translate the plugin you’re very welcome – simply leave a comment below with a link to the .po/.mo files for your language, or send me a pull request on GitHub.

Download P2 Header Ad

You can download the plugin from the official WordPress Plugin Repository:

The project is also on Github – feel free to fork and contribute:


The Changeling is best enjoyed at

Alternatively, you may track new and old releases on GitHub too:


If you enjoy my content, please consider supporting me on Ko-fi. In return you can browse this whole site without any pesky ads! More details here.

1 thought on “Introducing The P2 Header Ad Plugin”

Leave a Comment!

This site uses Akismet to reduce spam. Learn how your comment data is processed.