Advertisement
Digitalraindrops

Header Author Sample

Apr 28th, 2011
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.75 KB | None | 0 0
  1. <?php
  2. //Get the Author image by Digital Raindrops
  3. function dr_author_header() {
  4.     $style="";
  5.     if ( is_page() || is_single() ) {
  6.         $authorid =  $post[0]->post_author;
  7.         $slug = the_author_meta('user_nicename', $authorid );
  8.         if ( file_exists( get_template_directory_uri() .'/images/'.$slug.'.png' ) ) {
  9.             $link = the_author_meta( 'user_url', $authorid );
  10.             //Get author image by and the author url
  11.             $style = ' style="background-image: url(' .get_template_directory_uri() .'/images/'.$slug.'.png);" ';
  12.             $style = $style .'  onclick="location.href='.$link.'" ';
  13.         }
  14.     }
  15.     return $style;
  16. }
  17. ?>
  18.  
  19. <?php
  20.     //See if we want to swap the header banner and add a link
  21.     $style=dr_author_header();
  22. ?>
  23.     <div class="header-png"<?php echo $style; ?>></div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement