Custom headers and footers in WordPress

Today I wanted to put a custom post inside of a fancyBox popup. So, I wanted to have access to WordPress’s functions, but I didn’t want the usual header and footer from my main template… I just wanted a very basic page that would fit easily inside of fancyBox. I didn’t realize it, but WordPress allows you to load custom headers and footers by name using get_header and get_footer.

The naming structure is pretty simple. I copied header.php and renamed it “header-google_map.php.” Then, I stripped it pretty much bare keeping the wp_head(); function call in place so that I would have access to any scripts and styles used by installed plugins. Then, I called my bare-bones header file in a new template file using:

get_header( 'google_map' );

I did the same thing with the footer and this allowed me to have a simple, no-frills page perfect for displaying within a fancyBox. I could use shortcodes within the page and access all my installed plugins.

Leave a comment

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