Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function siiimple_query( $args ) {
- $q = array();
- if( $args['terms'] )
- $q['tax_query'] = array(
- array(
- 'taxonomy' => 'category',
- 'field' => 'id',
- 'no_found_rows' => true,
- 'terms' => $args['terms'],
- )
- );
- $q['post_offset'] = isset( $args['post_offset']) ? ((int) $args['post_offset']) : 0;
- $q['posts_per_page'] = $args['number'];
- $q['offset'] = isset( $args['page'] ) ? ( (int) $args['page'] - 1 ) * (int) $args['number'] : '';
- $wp_query = new WP_Query( $q );
- $count = count($wp_query->posts);
- if ( $wp_query->have_posts() ) :
- $num = 1;
- $html = '';
- while ( $wp_query->have_posts() ) :
- $wp_query->the_post();
- $grid = '';
- if( $args['column'] == 1 )
- $grid = 12;
- elseif( $args['column'] == 2 )
- $grid = 6;
- elseif( $args['column'] == 3 )
- $grid = 4;
- elseif( $args['column'] == 4 )
- $grid = 3;
- $grid_name = '';
- if( $args['column'] == 1 )
- $grid_name = 'siiimple-12';
- elseif( $args['column'] == 2 )
- $grid_name = 'siiimple-6';
- elseif( $args['column'] == 3 )
- $grid_name = 'siiimple-4';
- elseif( $args['column'] == 4 )
- $grid_name = 'siiimple-3';
- /*CONTACT WIDGET AUTHOR ABOUT THIS*/
- //if( $args['column'] != 1 && $num == 1 || $num % $args['column'] == 1 )
- if ( $args['show_gallery'] ) {
- $html .= '<div class="show-gallery">';
- } else {
- $html .= '<div class="row-siiimple">';
- }
- if ( $args['show_gallery'] ) {
- //Changed to 100 from 1 ask author
- $class = $args['column'] != 100 ? "cp-item-gallery col-sm-$grid col-md-$grid col-lg-$grid $grid_name" : "cp-item-gallery";
- } else {
- $class = $args['column'] != 100 ? "cp-item col-sm-$grid col-md-$grid col-lg-$grid $grid_name" : "cp-item";
- }
- $html .= ( stripslashes ("<div class='$class'>". siiimple_process_post( $args ) . "</div>"));
- //if( $args['column'] != 1 && $num % $args['column']== 0 || $num == $count )
- $html .= '</div>';
- $num++;
- endwhile;
- if ( $args['show_gallery'] ) {
- $html .= "<div class='clear' style='clear:both; height:0px;'></div>";
- } else {
- $html .= "<div class='clear' style='clear:both; height:1px;'></div>";
- }
- if ( $args['load_more'] && $wp_query->max_num_pages > 1 ) {
- $page = isset( $args['page'] ) ? $args['page'] : 1;
- $html .= "<div class='load-more' data-id='{$args['id']}' data-page='$page'>";
- $html .= "<p>- Load More -</p><a href='#'>". __( '<span>+</span>', SIIIMPLE_TEXTDOMAIN ) ."</a>";
- $html .= "</div>";
- }
- //Added for infinite scroll for sections
- //$html .= "<div class='fetch'>". next_posts_link( __( 'Load more posts', 'siiimple' ) ) . "</div>";
- wp_reset_postdata(); // reset the post globals as this query will shakes the party
- else:
- if( current_user_can('manage_options') )
- $html = __( 'There is no post for the current settings or the end of page.', SIIIMPLE_TEXTDOMAIN );
- endif;
- return $html;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement