Example #1
0
			<?php 
    if (!empty($img[0])) {
        ?>
				<div class="post-image">
					<a href="<?php 
        the_permalink();
        ?>
" class="post-image-link"><img src="<?php 
        echo esc_url($img[0]);
        ?>
" alt="post-img" class="post-inner-picture"></a>
					<?php 
        if (get_the_category_list(', ') != '') {
            ?>
						<div class="blog-category <?php 
            echo blogpost_get_random_circle();
            ?>
">
							<?php 
            echo get_the_category_list(', ');
            ?>
						</div>
					<?php 
        }
        ?>
					<?php 
        blogpost_get_favorite_icon(get_the_ID());
        ?>
				</div>
			<?php 
    }
Example #2
0
function blogpost_load_next_posts()
{
    $initial_posts = sanitize_text_field($_POST['initial_posts']);
    $next_posts = sanitize_text_field($_POST['next_posts']);
    $post_categories = sanitize_text_field($_POST['post_categories']);
    $post_paged = sanitize_text_field($_POST['post_paged']);
    $favorite = sanitize_text_field($_POST['favorite']);
    if ($favorite != '1') {
        query_posts(array('post_type' => 'post', 'posts_per_page' => $next_posts, 'category_name' => $post_categories, 'offset' => $post_paged));
    } else {
        query_posts(array('post_type' => 'post', 'posts_per_page' => $next_posts, 'offset' => $post_paged, 'post__in' => blogpost_get_user_favorites()));
    }
    if (!have_posts()) {
        wp_reset_query();
        wp_reset_postdata();
        return;
    }
    global $wp_query, $post;
    $max_pages = $wp_query->max_num_pages;
    $wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : ($current = 1);
    $max_posts = $wp_query->found_posts;
    ob_start();
    while (have_posts()) {
        the_post();
        $post_format = get_post_format();
        $img = wp_get_attachment_image_src(get_post_thumbnail_id(), 'blogpost-post-gallery-medium');
        $excerpt = get_the_excerpt();
        if ($post_format != '') {
            get_template_part('content', get_post_format());
        } else {
            ?>
			<li class="isotope-item blog-inner-container standart-format">
				<div  <?php 
            post_class();
            ?>
>
					<?php 
            if (!empty($img[0])) {
                ?>
						<div class="post-image">
							<a href="<?php 
                the_permalink();
                ?>
" class="post-image-link"><img src="<?php 
                echo esc_url($img[0]);
                ?>
" alt="post-img" class="post-inner-picture"></a>
							<?php 
                if (get_the_category_list(', ') != '') {
                    ?>
								<div class="blog-category <?php 
                    echo blogpost_get_random_circle();
                    ?>
">
									<?php 
                    echo get_the_category_list(', ');
                    ?>
								</div>
							<?php 
                }
                ?>
							<?php 
                blogpost_get_favorite_icon(get_the_ID());
                ?>
						</div>
					<?php 
            }
            ?>
					<div class="post-inner entry-content <?php 
            echo get_post_type();
            ?>
">
						<div class="blog-title">
							<a href="<?php 
            echo get_permalink($post->ID);
            ?>
"><?php 
            echo get_the_title();
            ?>
</a>
						</div>
						<div class="blog-excerpt">
						<?php 
            $post_content = '';
            if (empty($excerpt)) {
                _e('No excerpt for this posting.', 'blogpost-lite');
            } else {
                echo wp_kses($excerpt, array('a' => array('href' => array(), 'class' => array())));
            }
            ?>
						</div>
						<div class="blog-post-info">
							<div class="blog-comments icon-comment-1">
								<?php 
            $tc = wp_count_comments($post->ID);
            echo $tc->approved;
            ?>
							</div>
							<?php 
            if (empty($img[0])) {
                blogpost_get_favorite_icon(get_the_ID());
            }
            ?>
							<a href="<?php 
            echo get_permalink($post->ID);
            ?>
" class="blog-read-more ripple-slow wpb_button wpb_btn-danger wpb_regularsize square"><?php 
            _e('Read', 'blogpost-lite');
            ?>
</a>
							<div class="clearfix"></div>
						</div>
					</div>
				</div>
			</li>
		<?php 
        }
    }
    $post_content = ob_get_contents();
    ob_end_clean();
    wp_reset_query();
    wp_reset_postdata();
    $output = array('new_posts' => $post_content, 'pagination' => $max_posts);
    echo json_encode($output);
    die(1);
}