Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function clean_box_page_grid_content( $options ) {
- $quantity = $options['featured_grid_content_number'];
- global $post;
- $clean_box_page_grid_content = '';
- $number_of_page = 0; // for number of pages
- $page_list = array(); // list of valid page ids
- //Get number of valid pages
- for( $i = 1; $i <= $quantity; $i++ ){
- if( isset ( $options['featured_grid_content_page_' . $i] ) && $options['featured_grid_content_page_' . $i] > 0 ){
- $number_of_page++;
- $page_list = array_merge( $page_list, array( $options['featured_grid_content_page_' . $i] ) );
- }
- }
- if ( !empty( $page_list ) && $number_of_page > 0 ) {
- $get_featured_posts = new WP_Query( array(
- 'posts_per_page' => $quantity,
- 'post_type' => 'page',
- 'post__in' => $page_list,
- 'orderby' => 'post__in'
- ));
- $i=1;
- while ( $get_featured_posts->have_posts() ) {
- $get_featured_posts->the_post();
- $title_attribute = the_title_attribute( array( 'before' => __( 'Permalink to:', 'clean-box' ), 'echo' => false ) );
- $classes = 'page pageid-' . $post->ID;
- if ( 1 == $i ) {
- $classes .= ' first-cols';
- }
- $clean_box_page_grid_content .=
- '<a class="grid-box '. $classes .'" title="' . $title_attribute . '" href="' . get_permalink() . '">';
- if ( has_post_thumbnail() ) {
- if ( 1 == $i ) {
- $clean_box_page_grid_content .= get_the_post_thumbnail( $post->ID, 'clean-box-featured-grid', array( 'title' => esc_attr( $title_attribute ), 'alt' => esc_attr( $title_attribute ), 'class' => 'pngfix' ) );
- }
- else{
- $clean_box_page_grid_content .= get_the_post_thumbnail( $post->ID, 'clean-box-featured-content', array( 'title' => esc_attr( $title_attribute ), 'alt' => esc_attr( $title_attribute ), 'class' => 'pngfix' ) );
- }
- }
- else {
- //Default value if there is no first image
- $clean_box_image =
- '<img class="no-image pngfix" src="'.get_template_directory_uri().'/images/gallery/no-featured-image-800x450.jpg" />';
- //Get the first image in page, returns false if there is no image
- $clean_box_first_image = clean_box_get_first_image( $post->ID, 'medium', array( 'title' => esc_attr( $title_attribute ), 'alt' => esc_attr( $title_attribute ), 'class' => 'pngfix' ) );
- //Set value of image as first image if there is an image present in the post
- if ( '' != $clean_box_first_image ) {
- $clean_box_image = $clean_box_first_image;
- }
- $clean_box_page_grid_content .= $clean_box_image;
- }
- $clean_box_page_grid_content .= '
- <div class="caption">
- <span class="vcenter">
- <span class="entry-title">
- ' . the_title('', '', false) . '
- </span>
- <span class="more">';
- $clean_box_page_grid_content .= $options['excerpt_more_text'];
- $clean_box_page_grid_content .= '
- </span><!-- .more -->
- </span><!-- .vcenter -->
- </div><!-- .caption -->
- </a><!-- .grid-box -->';
- $i++;
- }
- wp_reset_query();
- }
- return $clean_box_page_grid_content;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement