Advertisement
srikat

Untitled

Mar 18th, 2015
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.17 KB | None | 0 0
  1. <?php
  2.  
  3. add_action( 'genesis_after_header', 'cyc_mid_section', 15 );
  4. function cyc_mid_section() {
  5.     // check if the flexible content field has rows of data
  6.     if( have_rows( 'page_builder' ) ) {
  7.         // loop through the rows of data  ?
  8.    
  9.         while ( have_rows( 'page_builder' ) ) : the_row();
  10.  
  11.             if ( get_row_layout() == 'gallery_row' ) {
  12.             // check if the repeater field has rows of data
  13.            
  14.                 if( have_rows( 'frontpage_gallery' ) ) {
  15.            
  16.                     echo '<div class="wrap fp-gallery">' ;
  17.            
  18.                     if ( is_main_site() ) {        
  19.                         echo '<h2>Our Venues - Quick Access</h2>';
  20.                     } else {
  21.                         echo '<h2>Our Features</h2>';
  22.                     }
  23.  
  24.                     $i = 0;
  25.                     while ( have_rows( 'frontpage_gallery' ) ) : the_row();
  26.                     $i++;
  27.                     if( $i % 3 == 1) { // this says, if the item number is divisible by 3 then
  28.                         $class = 'first' ;  // add this class
  29.                         $i = 1;  // then reset the counter back to 1
  30.                     }
  31.                     else {
  32.                         $class = ''; //otherwise don't output anything
  33.                         $image = wp_get_attachment_image_src( get_sub_field( 'gallery_image' ), 'gallery-feature' ); ?>
  34.                          <a href="<?php the_sub_field( 'gallery_link' ) ?>">
  35.                             <div class="one-third <?php echo $class ?>">
  36.                             <div class="fp-gallery-container">
  37.                             <?php if( get_sub_field( 'gallery_image_logo' ) ): ?>
  38.                                 <div class="fp-gallery-overlay" style="background: url(<?php the_sub_field( 'gallery_image_logo' ) ?> ) no-repeat; ">
  39.                                 </div>
  40.                                 <?php endif; ?>
  41.                                
  42.                                 <div class="fp-gallery-image">
  43.                                     <img src="<?php echo $image[0]; ?>" alt="<?php echo the_sub_field( 'gallery_image_caption' ) ?>" />
  44.                                 </div>
  45.                                 <div class="fp-gallery--caption <?php the_sub_field( 'gallery_colour_scheme' ) ?>">
  46.                                 <?php the_sub_field( 'gallery_image_caption' ) ?><span class="fa-stack"><i class="fa fa-circle fa-stack-2x"></i><i class="fa fa-play fa-stack-1x fa-inverse"></i></span>
  47.                                 </div>
  48.                             </div>
  49.                             </div>
  50.                          </a>
  51.                         <?php } endwhile;
  52.  
  53.                         ?></div><!-- end fp-gallery -->
  54.  
  55.                     <?php }
  56.                 else {
  57.                     // no rows found
  58.                 }
  59.  
  60.             }
  61.  
  62.     }
  63.    
  64.     endwhile;
  65.  
  66.     else {
  67.         // no layouts found
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement