Wordpress Plugin: Post/Page Headers
Post/Page Headers is a simple Wordpress plugin that lets you add Stylesheet and JavaScript files (CSS & JS) to your posts and pages.
After being frustrated about having to add styles to my theme’s CSS file everytime I wanted to add a new div or span style to a post, I decided to write this plugin so that no longer had to be done.
What does this Plugin do?
Instead of having to edit your theme styles everytime you want to add a new style to a post, you can load a separate file for just that post. Same goes for JavaScript.
This plugin queue’s your files with wp_enqueue_style() and wp_enqueue_script() when the associated post is being displayed. If you choose to load your script in the footer, then when wp_foot() i called, the scripts are added there.
How to use Post Headers Plugin
When adding/edited an entry, a new meta box will appear titled Post Headers or Page Headers depending on whether you’re editing a post or a page..
To add a file, simply paste the url into the input box, select the type of file, and where its to be placed. When you save the post/page, the data will be saved. To add more than one script, click the Add Another Script button, and a new row will be added.
To upload a file, simply click the Upload Files button. Once you have uploaded the file, copy the url, and paste it into the appropriate box.
To delete a file, click the X button, and save the post/page.
Allowed files are CSS, JS, and PHP files. PHP files are allowed because some prefer use PHP files to dynamically load scripts.
Download
Download Stats
| Today: | 2 |
| Yesterday: | 4 |
| This Week: | 18 |
| Total: | 790 |
August 3rd, 2009 // Plugins |


Hi I was wondering if this plugin could be used for loading google website optimizer code to the header of a test page?
Nice plugin. But I couldn’t make it run on WP 2.8.6. Perhaps it needs an update. Perhaps I do something wrong. Could you confirm if it has been tested with WP 2.8.6, please? Thank you very much.
I can confirm that this plugin does work for 2.8.6.
One thing is for the script to be added, you need to either save or publish the post when you add/change/remove scripts. Simply clicking preview doesn’t save the the changes for the preview.
Let me know if that’s not the issue.
Thanks for your reply.
The problem was when trying to save the post. I received the next warning:
“Warning: Missing argument 1 for post_head_get_files(), called in …blog/wp-content/plugins/postpage-headers/post-headers.php on line 92 and defined in …blog/wp-content/plugins/postpage-headers/post-headers.php on line 104″
So I’ve modified the file in line 92 giving the missing parameter: $post_ID
$data = post_head_get_files($post_ID);
This looks to be the solution. But I have a question: If no other people have notice this simple problem I had, How is it possible the script had been running for them with this missing parameter?
Thank you very much again for your work.
Probably a stupid question, but here goes:
Ok, so I upload a new stylesheet for the given post or page. Most of the changes I am going to want to make are simple things like switching the page background image, or changing the font colors.
Obviously I would not be changing the css names themselves, just the attributes.
So will this plugin override my themes normal css file?
example: current style says-
}
#header-nav-combo {
background:transparent url(images/imagexyz.png) repeat-x scroll 0 0;
but on my ‘custom page’ I want to replace that with
}
#header-nav-combo {
background:transparent url(images/imageABC.png) repeat-x scroll 0 0;
So does the #header-nav-combo from the stylesheet I upload and assign to the custom page take priority over my default stylesheet?
If you want to ensure that your costume CSS overrides your template CSS, I suggest adding the
!importantdeclaration.For example:
#header-nav-combo {background:transparent url(images/imageABC.png) repeat-x scroll 0 0 !important;
}
By default the post stylesheets are added using the
wp_enqueue_style()function, and because every theme is different, there’s no telling how the theme stylesheet is added and whether it would be placed before of after the new one.Therefore,
!importantis the safest way to go.