Exemplo n.º 1
0
?>
	<div class="main-content container">
		<div class="main-content-column col-md-<?php 
print is_active_sidebar('primary-sidebar') ? 8 : 12;
?>
">
			<?php 
if (have_posts()) {
    // Start the Loop.
    while (have_posts()) {
        the_post();
        /*
         * Include the post format-specific template for the content. If you want to
         * use this in a child theme, then include a file called called content-___.php
         * (where ___ is the post format) and that will be used instead.
         */
        get_template_part('content', get_post_format());
    }
    gazeta_the_posts_pagination(null, true);
} else {
    // If no content, include the "No posts found" template.
    get_template_part('content', 'none');
}
?>
		</div>
		<?php 
get_sidebar();
?>
	</div>
<?php 
get_footer();
Exemplo n.º 2
0
    /**
     * Main Posts Shortcode
     * @param unknown_type $attr
     * @param unknown_type $content
     * @return mixed|string|unknown|Ambigous <string, mixed>
     */
    function gazeta_grid_posts_shortcode($attr, $content = null)
    {
        $output = '';
        $current_post = get_the_ID();
        wp_reset_postdata();
        extract(shortcode_atts(array('heading' => '', 'id' => 'grid-post-' . rand(1000, 9999), 'columns' => 3, 'author__in' => '', 'post_format' => '', 'post_tags' => '', 'categories' => '', 'ignore_sticky_posts' => 'yes', 'orderby' => 'ID', 'order' => 'DESC', 'posts_per_page' => get_option('posts_per_page'), 'thumbnail_size' => 'image-370-243', 'hide_post_no_featured_image' => '', 'el_class' => '', 'show_excerpt' => '', 'excerpt_length' => 30, 'expiration' => '300', 'main_query' => ''), $attr));
        $columns = (int) $columns;
        $bt_column_class = 12 % $columns == 0 && 12 >= $columns ? 12 / $columns : 1;
        $post_data = array('no_found_rows' => true, 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => $posts_per_page, 'orderby' => $orderby == 'view' ? 'meta_value_num' : $orderby, 'order' => $order, 'post__not_in' => isset($current_post) ? array($current_post) : '');
        // order by views
        if ($orderby == 'view') {
            $post_data['meta_key'] = defined('GAZETA_POST_VIEWS_FIELD_NAME') ? GAZETA_POST_VIEWS_FIELD_NAME : 'post_views';
        }
        // Post formats
        if (!empty($post_format)) {
            $post_format = explode(",", $post_format);
            if (is_array($post_format) && !empty($post_format)) {
                $post_data['tax_query'][] = array('taxonomy' => 'post_format', 'field' => 'slug', 'terms' => $post_format, 'operator' => 'IN');
            }
        }
        if (!empty($author__in)) {
            $author__in = explode(",", $author__in);
            if (is_array($author__in) && !empty($author__in)) {
                $post_data['author__in'] = $author__in;
            }
        }
        // Post Tags
        if (!empty($post_tags)) {
            $post_tags = explode(",", $post_tags);
            if (is_array($post_tags) && !empty($post_tags)) {
                $post_data['tag_slug__in'] = $post_tags;
            }
        }
        // $sticky
        if ($ignore_sticky_posts == 'yes' || $ignore_sticky_posts === true) {
            $post_data['ignore_sticky_posts'] = true;
        }
        if ($hide_post_no_featured_image == 'yes') {
            $post_data['meta_query'] = array(array('key' => '_thumbnail_id', 'compare' => '!=', 'value' => ''));
        }
        if (!empty($categories)) {
            $categories = explode(",", $categories);
            if (is_array($categories) && !empty($categories)) {
                $post_data['category__in'] = $categories;
            }
        }
        if ($main_query == 'yes') {
            if (gazeta_get_paged()) {
                // delete the cache.
                delete_transient($id);
            }
            $post_data['paged'] = gazeta_get_paged();
            $post_data['no_found_rows'] = false;
        }
        if (false !== ($output = get_transient($id)) && apply_filters('is_cache_active', true) === true) {
            // check if the cache is exists.
            return $output;
        } else {
            $post_data = apply_filters('gazeta_grid_posts/args', $post_data, $id);
            $post_query = new WP_Query($post_data);
            if ($post_query->have_posts()) {
                // start the query.
                $output .= '<div id="' . esc_attr($id) . '" class="col-md-12 grid-posts ' . esc_attr($el_class) . '">';
                if (!empty($heading)) {
                    $output .= '<h5><span>' . esc_attr($heading) . '</span></h5>';
                }
                $output .= '<div class="row">';
                // Loop content.
                while ($post_query->have_posts()) {
                    $post_query->the_post();
                    $output .= '
							<div class="responsive-height col-md-' . esc_attr($bt_column_class) . '">
								<a href="' . get_permalink(get_the_ID()) . '">
									<div class="news-thumb">';
                    if (has_post_thumbnail(get_the_ID())) {
                        $output .= get_the_post_thumbnail(get_the_ID(), apply_filters('gazeta_grid_posts/thumbnail_size', $thumbnail_size, $id), array('class' => 'img-responsive'));
                    }
                    $output .= '<h4 class="post-title">' . get_the_title(get_the_ID()) . '</h4>';
                    if (get_post_format(get_the_ID()) == 'video') {
                        $output .= '<i class="fa fa-play"></i>';
                    }
                    $output .= '
									</div>
								</a>
							</div>					
						';
                }
                $output .= '</div>';
                // end row.
                $output .= '</div>';
                // end block
                // end query.
                if ($main_query == 'yes') {
                    $output .= gazeta_the_posts_pagination($post_query, false);
                }
            }
            if (apply_filters('is_cache_active', true) === true) {
                set_transient($id, $output, apply_filters('transient_expiration', $expiration));
            }
            wp_reset_postdata();
            return $output;
        }
    }