I am calling the header on a custom template page with get_header();
but the header loads without the style.css breaking the site. I noticed that if I place the header on top of some code, the style sheet loads just fine, for example:
<?php
/*
Template Name: Sample Template
*/
get_header();
//some code here
I need to load the header below some code since I am using a cookie and as of my knowledge, cookies should be generated before any HTML.
Don’t place any code above
get_header()
. Instead, use actions to “hook” and do some work there.For example, you could use
get_header
action like this:See http://codex.wordpress.org/Plugin_API/Action_Reference/get_header
And more about actions: http://codex.wordpress.org/Plugin_API
It might take a bit to get one’s head around actions (and filters) at first, but those are crucial concepts in WordPress, so it’s definitely worth it!