Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to filter the get_header function on an specific page template to use a custom header located on my plugin folder.

So instead of outputting the theme header, it'd output a custom header from my plugin.

Is this doable?

share|improve this question
add comment

2 Answers

get_header() is not filterable. Neither is locate_template().

Themes can alter which header loads by passing a parameter to get_header(). There is no obvious way that I see for plugins to alter which header loads. As I think about it, that makes a lot of sense. It would be fantastically easy for plugins to break themes by altering the header.

You can hook into get_header or wp_head to add things to the header, if that helps. If the "specific page template" is one that the plugin controls then you can write your header into the template.

If you explain why you want to do this a better answer may be possible.

share|improve this answer
add comment

Err, Maybe I'm overtired but why don't you just duplicate the page template and hack the get_header()

<?php get_header( 'edhead' ); ?>

Which will call header-edhead.php instead of header.php

Then switch the page template to this template.

http://codex.wordpress.org/Function_Reference/get_header

share|improve this answer
    
The OP wants to have the custom header in a plugin's folder, not in the theme folder. Otherwise, yes, your answer is the way to go. –  Pat J Aug 26 '13 at 21:15
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.