/** * Render main shortcode. * * @since 1.0.0 * @access public * @param array $atts * @param string $content * @return string */ public function render_shortcode($original_atts, $content = null) { global $wp_query, $query_string, $TF; $atts = shortcode_atts(array('layout' => 'post-list', 'offset' => 0, 'post_per_page' => -1, 'order' => 'DESC', 'orderby' => 'date', 'pagination' => 'no', 'category' => array(0)), $original_atts, $this->shortcode); $output = ''; $paged = $this->get_paged_query(); $atts['category'] = html_entity_decode($atts['category'], ENT_COMPAT); $atts['category'] = maybe_unserialize($atts['category']); if (!$atts['category'] || empty($atts['category'])) { return false; } $build_query = array('order' => $atts['order'], 'orderby' => $atts['orderby']); $non_category = array_search(0, $atts['category']); $build_query['category__in'] = array(); if ($non_category !== false) { $categories = get_terms('category', array('hide_empty' => true)); foreach ($categories as $c) { $build_query['category__in'][] = $c->term_id; } } else { $build_query['category__in'] = $atts['category']; } $build_query['posts_per_page'] = $atts['post_per_page'] && $atts['post_per_page'] > 0 ? $atts['post_per_page'] : -1; $build_query['offset'] = ($paged - 1) * $atts['post_per_page'] + $atts['offset']; $build_query['nopaging'] = $build_query['posts_per_page'] == -1; $query = new WP_Query(build_query($build_query)); if ($query->have_posts()) { ob_start(); ?> <!-- loopswrapper --> <div class="tf_loops_wrapper clearfix <?php echo esc_attr($atts['layout']); ?> "> <?php $TF->in_archive_loop = true; while ($query->have_posts()) { $query->the_post(); ?> <?php do_action('tf_list_post_before_post'); ?> <article <?php echo tf_get_attr('post', $original_atts); ?> > <?php do_action('tf_list_post_start_post'); ?> <?php echo do_shortcode($content); ?> <?php do_action('tf_list_post_end_post'); ?> </article> <?php do_action('tf_list_post_after_post'); ?> <?php } $TF->in_archive_loop = false; ?> </div><!-- /tf_loops_wrapper --> <?php // Pagination links if ('yes' == $atts['pagination']) { echo tf_get_pagenav('', '', $query); } $output = ob_get_contents(); ob_get_clean(); } wp_reset_query(); wp_reset_postdata(); return $output; }
/** * Echoes page navigation * @uses themify_get_pagenav * @since 1.0.0 */ function tf_pagenav($before = '', $after = '', $query = false) { echo tf_get_pagenav($before, $after, $query); }