Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!

Header Author Sample

By: Digitalraindrops on Apr 28th, 2011  |  syntax: PHP  |  size: 0.75 KB  |  views: 221  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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>
clone this paste RAW Paste Data