Advertisement
srikat

page.php

Mar 22nd, 2015
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.83 KB | None | 0 0
  1. <?php
  2.  
  3. function sk_display_fc() {
  4.     // loop through the rows of data
  5.     while ( have_rows('flexible_content') ) : the_row();
  6.  
  7.         if( get_row_layout() == 'hero' ) {
  8.  
  9.             $hero_image = get_sub_field( 'hero_image' ); ?>
  10.  
  11.             <div class="hero" style="background-image: url(<?php the_sub_field( 'hero_image' ); ?>);">
  12.                 <div class="dark-overlay">
  13.                     <div class="wrap">
  14.                         <?php the_sub_field( 'hero_text' );
  15.                         if( get_field( 'display_cta_button' ) ) { ?>
  16.                             <a href="<?php the_sub_field( 'hero_cta_button_url' ) ?>" class="button"><?php echo the_sub_field( 'hero_cta_button_text' );?></a>
  17.                         <?php } ?>
  18.                     </div>
  19.                 </div>
  20.             </div>
  21.            
  22.             <?php
  23.  
  24.         } elseif( get_row_layout() == 'home_image_section' ) {
  25.  
  26.             $image = get_sub_field( 'home_image_section' );
  27.             echo '<div class="row image home-section"><img src="' . $image['url'] . '" alt="' . $image['alt'] . '" /></div>';
  28.  
  29.         }
  30.  
  31.     endwhile;
  32. }
  33.  
  34. add_action( 'get_header', 'sk_fc_check' );
  35. function sk_fc_check() {
  36.     if( have_rows( 'flexible_content' ) ) {
  37.         remove_action( 'genesis_entry_content', 'genesis_do_post_content' );
  38.         add_action( 'genesis_entry_content', 'sk_display_fc' );
  39.  
  40.         // Add support for structural wraps
  41.         add_theme_support( 'genesis-structural-wraps', array(
  42.             'header',
  43.             'nav',
  44.             'subnav',
  45.             // 'site-inner',
  46.             'footer-widgets',
  47.             'footer'
  48.         ));
  49.  
  50.         add_filter( 'body_class', 'sk_body_class' );
  51.  
  52.         // Remove the entry title (requires HTML5 theme support)
  53.         remove_action( 'genesis_entry_header', 'genesis_do_post_title' );      
  54.         // Remove entry header markup
  55.         remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_open', 5 );
  56.         remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_close', 15 );
  57.     }
  58. }
  59.  
  60. function sk_body_class( $classes ) {
  61.     $classes[] = 'flexible-content';
  62.     return $classes;
  63. }
  64.  
  65. genesis();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement