Advertisement
Digitalraindrops

Header Category Image

Jul 24th, 2011
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.60 KB | None | 0 0
  1. $slug="";
  2. if ( is_category() ) {
  3.     /* category.php or archive.php */
  4.     global $cat;
  5.     $curr_cat = get_category($cat);
  6.     $slug = $curr_cat->slug;
  7. } elseif ( is_single() ) {
  8.     /* It is a post get the first category header */
  9.     global $post;
  10.     $categories = get_the_category($post->ID);
  11.     if($categories) {
  12.         $slug = $categories[0]->slug;
  13.     }      
  14. }
  15. if ($slug) {
  16.     //load header image
  17.     if(file_exists( STYLESHEETPATH .'/images/headers/' .$slug .'.png') ) {
  18.         $imguri = get_stylesheet_directory_uri() .'/images/headers/' .$slug .'.png';
  19.         ?>
  20.         <!-- Here is where the header image html would be -->
  21.         <?php
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement