Example of wrapping a custom header or footer around WordPress pages.
-
*NOTE: This only shows you how to call custom header or footer code to wrap your WordPress pages around. You still need to edit your theme to remove the default header or footer that comes with WordPress. Sidebars have not been considered as part of this solution*
I spent a good couple of hours trying to work out, how to integrate WordPress into the current setup of my website. I have a basic site:- Front page (custom), Blog (WordPress, soon to be former Simple PHP Blog) and a Gallery (Coppermine).
My header includes the Title of my Site, a lovely pic of me, and the navigation to the gallery or blog (and keywords in the code)
The footer is just that, a picture of my feet.I didn’t want to use the delivered WP header or footer, because it did not match into my already existing website style. If I was starting off fresh, then maybe yes, the delivered H&Fs might have been perfect for integration with other packages. I just needed WordPress to fit between the two, to give consistency between the pages.
My custom header.php and footer.php are in their own folder called ‘wrapper’, that sits in the root of my site where they can be called anytime from anywhere.
To make sure WordPress called these two files, I edited the following file:
wp-blog-header.php<?php /** * Loads the WordPress environment and template. * * @package WordPress */ //This line calls the custom header.php file, before WordPress calls the template include ("../wrapper/header.php"); if ( !isset($wp_did_header) ) { $wp_did_header = true; require_once( dirname(__FILE__) . '/wp-load.php' ); wp(); require_once( ABSPATH . WPINC . '/template-loader.php' ); } //This line calls the custom footer.php file, after WordPress has called the template include ("../wrapper/footer.php"); ?>
Once you have this in place, you still need to edit the template files to remove the default delivered Header and Footer code. It may look ugly, but it works for me.
I tried to use these support forms to find any existing solutions, but the ones I kept finding just didn’t match my requirements. I also found the level of support to be quite sneering of this type of request, as if by trying to have your own header or footer was offensive to those of the ‘Pure WordPress’ breed, that WP as delivered is perfect and requires no changes or hacks.
If you don’t have an answer, don’t post. If your answer doesn’t match the poster’s requirements, don’t bitch about it. Everybody has their own idea on how their site should look, and this includes WordPress.
- The topic ‘Example of wrapping a custom header or footer around WordPress pages.’ is closed to new replies.