Advertisement
catchmahesh

Gridalicious - Remove Permalink to: from Grid

Mar 2nd, 2017
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.76 KB | None | 0 0
  1. function gridalicious_page_grid_content( $options ) {
  2.     $quantity       = $options['featured_grid_content_number'];
  3.  
  4.     global $post;
  5.  
  6.     $gridalicious_page_grid_content = '';
  7.     $number_of_page         = 0;        // for number of pages
  8.     $page_list              = array();  // list of valid page ids
  9.  
  10.     //Get number of valid pages
  11.     for( $i = 1; $i <= $quantity; $i++ ){
  12.         if( isset ( $options['featured_grid_content_page_' . $i] ) && $options['featured_grid_content_page_' . $i] > 0 ){
  13.             $number_of_page++;
  14.  
  15.             $page_list  =   array_merge( $page_list, array( $options['featured_grid_content_page_' . $i] ) );
  16.         }
  17.  
  18.     }
  19.  
  20.     if ( !empty( $page_list ) && $number_of_page > 0 ) {
  21.         $loop = new WP_Query( array(
  22.             'posts_per_page'    => $quantity,
  23.             'post_type'         => 'page',
  24.             'post__in'          => $page_list,
  25.             'orderby'           => 'post__in'
  26.         ));
  27.  
  28.         $i=1;
  29.  
  30.         while ( $loop->have_posts() ) {
  31.  
  32.             $loop->the_post();
  33.  
  34.             $title_attribute = the_title_attribute( array( 'echo' => false ) );
  35.  
  36.             $classes = 'page pageid-' . $post->ID;
  37.  
  38.             if ( 1 == $i ) {
  39.                 $classes .= ' first';
  40.             }
  41.             else if ( 1 == $i%3 ) {
  42.                 $classes .= ' first-cols';
  43.             }
  44.  
  45.             $gridalicious_page_grid_content .=
  46.             '<a class="grid-box '. $classes .'" title="' . the_title_attribute( array( 'echo' => false ) ) . '" href="' . esc_url( get_permalink() ) . '">';
  47.  
  48.             if ( has_post_thumbnail() ) {
  49.                 $gridalicious_page_grid_content .= get_the_post_thumbnail( $post->ID, 'gridalicious-featured-grid', array( 'title' => $title_attribute, 'alt' => $title_attribute, 'class'  => 'pngfix' ) );
  50.             }
  51.             else {
  52.                 //Default value if there is no first image
  53.                 $gridalicious_image =
  54.                     '<img class="no-image pngfix" src="'.get_template_directory_uri().'/images/gallery/no-featured-image-1200x514.jpg" />';
  55.  
  56.                 //Get the first image in page, returns false if there is no image
  57.                 $gridalicious_first_image = gridalicious_get_first_image( $post->ID, 'medium', array( 'title' => $title_attribute, 'alt' => $title_attribute, 'class' => 'pngfix' ) );
  58.  
  59.                 //Set value of image as first image if there is an image present in the post
  60.                 if ( '' != $gridalicious_first_image ) {
  61.                     $gridalicious_image =   $gridalicious_first_image;
  62.                 }
  63.  
  64.                 $gridalicious_page_grid_content .= $gridalicious_image;
  65.             }
  66.  
  67.             $gridalicious_page_grid_content .= '
  68.                 <div class="caption">
  69.                     <span class="vcenter">
  70.                         <span class="entry-title">
  71.                             ' . the_title('', '', false) . '
  72.                         </span>
  73.                         <span class="more">';
  74.  
  75.                         $gridalicious_page_grid_content .=  $options['excerpt_more_text'];
  76.  
  77.                 $gridalicious_page_grid_content .= '
  78.                         </span><!-- .more -->
  79.                     </span><!-- .vcenter -->
  80.                 </div><!-- .caption -->
  81.             </a><!-- .grid-box -->';
  82.  
  83.             $i++;
  84.         }
  85.  
  86.         wp_reset_query();
  87.     }
  88.  
  89.     return $gridalicious_page_grid_content;
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement