Reputation: 4218
I am making a wordpress theme. Normally I have a header file, but I want it to slightly differ from page to page, that is I want it to contain additional text that is different for each page (and is not general, like an article title, but it's like on one page I need a title, on the other a link, etc.)
What is the best practice to do this? Change the text from JavaScript? I don't want to have separate header files, just to somehow change text in a div included in this header file.
Upvotes: 0
Views: 99
Reputation: 977
Does this do something for 'ya?
<?php
if (function_exists('is_tag') && is_tag()) {
single_tag_title("Tag archive fot ""); echo '" - '; }
elseif (is_archive()) {
wp_title(''); echo ' archive - '; }
elseif (!(is_404()) && (is_single()) || (is_page())) {
wp_title(''); echo ' - '; }
elseif (is_404()) {
echo 'Whoops, nothing here! - '; }
if (is_home()) {
bloginfo('name'); echo ' - '; bloginfo('description'); }
else {
bloginfo('name'); }
if ($paged>1) {
echo ' - page '. $paged; }
?>
With conditional tags you can server different stuff for certain pages.
/Paul
Upvotes: 1
Reputation: 5397
This depends on how much change is needed. I am guessing that you can have a function or a different file included in header.php
A very common way to approach this would be to have different header files in your theme. By default you should have a header.php file. You could also create files like header-name.php and use the optional parameter for the get_header function.
In your themes the header file is included by using the get_header function but usually with no parameter. But if you use it like this:
get_header('name');
the custom file header-name.php will be used. You could as well use different pages templates (see this) for some sections and each could include a different header file using the method described above.
Upvotes: 0