Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //This goes in header.php where the header image is loaded.
- $slug="";
- if ( is_category() ) {
- /* category.php or archive.php */
- global $cat;
- $curr_cat = get_category($cat);
- $slug = $curr_cat->slug;
- } elseif ( is_single() ) {
- /* It is a post get the first category header */
- global $post;
- $categories = get_the_category($post->ID);
- if($categories) {
- $slug = $categories[0]->slug;
- }
- }
- if ($slug) {
- //load header image
- if(file_exists( STYLESHEETPATH .'/images/headers/' .$slug .'.png') ) {
- $imguri = get_stylesheet_directory_uri() .'/images/headers/' .$slug .'.png';
- ?>
- <!-- Here is where the header image html would be -->
- <?php
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement