r.kathuria
r.kathuria

Reputation: 13

want to add different header file to custom template

I want to add different header file to custom wordpress page template. I created a new template for custom post type. I want to add a header file to it using get_header() function, but do not want to use the regular header of the theme. I can paste the entire changed header file into the template, but I don't think that is the correct way. Any suggestions would be helpful.

Thanks

Upvotes: 1

Views: 2738

Answers (3)

Samir Sheikh
Samir Sheikh

Reputation: 2401

You just create a different header file in you current theme just like header-custom.php

This example will include header-custom.php

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

Upvotes: 0

Deepti chipdey
Deepti chipdey

Reputation: 1177

you can create the header file for every template, for example, to call header-blog.php: you need to get_header('blo');

Upvotes: 1

Vincens von Bibra
Vincens von Bibra

Reputation: 113

I would suggest only replacing the content in the header-file based on the template. You can therefore add a block just for the template "about.php" like this:

if(is_page_template( 'templates/about.php' ) {
    //custom header for about.php

} else {
    //Header for all other pages

}

Upvotes: 0

Related Questions