} ?> <?php $counter = themeblvd_set_att('counter', $counter + 1); ?> <?php } ?> <?php if ($counter - 1 != themeblvd_get_att('posts_per_page')) { ?> <?php themeblvd_close_row(); ?> <!-- ROW (end) --> <?php } ?> <?php } else { ?> <p><?php echo themeblvd_get_local('archive_no_posts'); ?> </p>
/** * Display paginated post list or post grid * * @since 2.0.0 * * @param array $options all options for posts * @param string $type Type of posts, grid or list * @param string $current_location Current location of element, featured or primary */ function themeblvd_posts_paginated($args = array(), $type = 'list', $current_location = 'primary') { global $more; // Current location if relevant $location = themeblvd_set_att('location', $current_location); // Setup and extract $args $defaults = array('source' => '', 'categories' => array('all' => 1), 'tag' => '', 'thumbs' => 'default', 'content' => 'default', 'columns' => '3', 'rows' => '3', 'posts_per_page' => '6', 'orderby' => 'date', 'order' => 'DESC', 'offset' => '0', 'query' => '', 'crop' => ''); $args = wp_parse_args($args, $defaults); extract($args, EXTR_OVERWRITE); // Config before query string if ($type == 'grid') { $columns = themeblvd_set_att('columns', $columns); $posts_per_page = $rows ? $columns * $rows : '-1'; $args['posts_per_page'] = $posts_per_page; // Set new value to $args for parsing query $size = themeblvd_set_att('size', themeblvd_grid_class($columns)); $crop = !empty($crop) ? $crop : $size; $crop = themeblvd_set_att('crop', $crop); } else { $posts_per_page = themeblvd_set_att('posts_per_page', $posts_per_page); $content = $content == 'default' ? themeblvd_get_option('blog_content', null, 'content') : $content; $content = themeblvd_set_att('content', $content); $size = $thumbs == 'default' ? themeblvd_get_option('blog_thumbs', null, 'small') : $thumbs; $size = themeblvd_set_att('size', $size); } /*------------------------------------------------------*/ /* Query Args /*------------------------------------------------------*/ // Set the second query in global $themeblvd_query. // We only do this for paginated queries. $query_args = themeblvd_set_second_query($args, $type); // Sets global var and gets for local var // Apply filters $query_args = apply_filters('themeblvd_posts_args', $query_args, $args, $type, $current_location); /*------------------------------------------------------*/ /* The Loop /*------------------------------------------------------*/ // Query posts $posts = new WP_Query($query_args); // Start output echo '<div class="post_' . $type . '">'; if ($posts->have_posts()) { do_action('themeblvd_post_' . $type . '_paginated_before_loop', $args); if ($type == 'grid') { // Loop for post grid $counter = themeblvd_set_att('counter', 1); while ($posts->have_posts()) { $posts->the_post(); $more = 0; // If this is the very first post, open the first row if ($counter == 1) { themeblvd_open_row(); } // Get template part, framework default is content-grid.php get_template_part('content', themeblvd_get_part('grid_paginated')); // If last post in a row, close the row if ($counter % $columns == 0) { themeblvd_close_row(); } // If first post in a row, open the row if ($counter % $columns == 0 && $posts_per_page != $counter) { themeblvd_open_row(); } // Increment the counter with global template attribute accounted for $counter = themeblvd_set_att('counter', $counter + 1); } // In case the last row wasn't filled, close it now if ($counter - 1 != $posts_per_page) { themeblvd_close_row(); } } else { // Loop for post list while ($posts->have_posts()) { $posts->the_post(); $more = 0; // Get template part, framework default is content-list.php get_template_part('content', themeblvd_get_part('list_paginated')); } } do_action('themeblvd_post_' . $type . '_paginated_after_loop', $args); } else { // No posts to display printf('<p>%s</p>', themeblvd_get_local('archive_no_posts')); } // Pagination themeblvd_pagination($posts->max_num_pages); echo '</div><!-- .post_' . $type . ' (end) -->'; // Reset Post Data wp_reset_postdata(); }