Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2011
1,059
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.45 KB | None | 0 0
  1. /**
  2.  * Set Up Intro Box
  3.  * @link http://www.therivercentre.org
  4.  * @author Bill Erickson
  5.  *
  6.  */
  7.  
  8. add_action('genesis_before_content', 'be_intro_box');
  9. function be_intro_box() {
  10. if(is_page() && !is_front_page()):
  11.     global $post;
  12.     // Get the custom fields for the intro box line one and two
  13.     $intro_text_line_1 = get_custom_field('_river_intro_text', $post->ID);
  14.     $intro_text_line_2 = get_custom_field('_river_intro_text_2', $post->ID);
  15.     if (!$intro_text_line_1 && !$intro_text_line_2):
  16.         // If the intro box lines are empty, get them from the parent page
  17.         $intro_text_line_1 = get_custom_field('_river_intro_text', $post->post_parent);
  18.         $intro_text_line_2 = get_custom_field('_river_intro_text_2', $post->post_parent);
  19.     endif;
  20.  
  21.     // Get the post thumbnail
  22.     $image = get_the_post_thumbnail($post->ID, 'river_top');
  23.     // If no post thumbnail, get from the parent
  24.     if (!$image) $image = get_the_post_thumbnail($post->post_parent, 'river_top');
  25.  
  26.     // If we have an image and intro text, display it
  27.     if ($image && $intro_text_line_1):
  28.         echo '<div class="intro-box clearfix">';
  29.         if (!$intro_text_line_2) {
  30.             echo '<div class="intro-text custom-background"><span>'. $intro_text_line_1. '</span></div>';
  31.         } else {
  32.             echo '<div class="intro-text custom-background"><span><strong>'. $intro_text_line_1. '</strong><br />'.$intro_text_line_2.'</span></div>';     
  33.         }
  34.         echo '<div class="intro-image">'. $image . '</div>';
  35.         echo '</div>';
  36.     endif;
  37. endif;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement