[Explanation] How to get a Different Header for a special page
-
Hi,
I am making a subdomain and doing some linking and wanted to have one special page have a different header.
I don’t know much about php and google didnt help me. In the end i ended up creating some kind of code.I’ll show you how to do this with the defualt wp skin(header.php skin file):
<div id="header" onclick="location.href='https://yourdomain.com/';" style="cursor: pointer;"> <div id="headerimg"> <h1><a href="<?php echo get_option('home'); ?>/"><?php bloginfo('name'); ?></a></h1> <div class="description"><?php bloginfo('description'); ?></div> </div> </div>
Now just change it to this this code:
<?php if ( $paged('113')) { ?> <!--Here you can add the page number (find it in the URL or while editingin the URL)--> <div id="header" onclick="location.href='https://fuerfrei.de/';" style="cursor: pointer;"> <div id="headerimg"> <h1><a href="<?php echo get_option('home'); ?>/"><?php bloginfo('name'); ?></a></h1> <div class="description"><?php bloginfo('description'); ?></div> </div> </div> <?php } elseif ( $paged('46')) { ?> <!--Use the elseif code once or multiple types if u want more than one page with a custom header--> <div id="header" onclick="location.href='https://fuerfrei.de/';" style="cursor: pointer;"> <div id="headerimg"> <h1><a href="<?php echo get_option('home'); ?>/"><?php bloginfo('name'); ?></a></h1> <div class="description"><?php bloginfo('description'); ?></div> </div> </div> <?php } else { ?> <!--This Header will be shown everywhere, where you haven't defined a custom one --> <div id="header" onclick="location.href='https://fuerfrei.de/';" style="cursor: pointer;"> <div id="headerimg"> <h1><a href="<?php echo get_option('home'); ?>/"><?php bloginfo('name'); ?></a></h1> <div class="description"><?php bloginfo('description'); ?></div> </div> </div> <?php } ?>
Now i think this should get you to have your own header on the page you defined with if or elseif.
As i searched for quite a while i hope this helps other People looking for the same thing a small idea on how to do it.
Please correct me if this is a bad way to do it, but it seems to work and seems easy for me(as i dont really know php very well).
- The topic ‘[Explanation] How to get a Different Header for a special page’ is closed to new replies.