Пример #1
0
if (have_posts()) {
    ?>
    <div id="main" role="main" class="masonry" >
        <?php 
    $first = true;
    ?>
        <?php 
    while (have_posts()) {
        the_post();
        ?>
            <?php 
        $block_class = 'block';
        if (dw_is_featured_post()) {
            $block_class .= ' w2';
        }
        if ($first && !dw_is_featured_post()) {
            $first = false;
            $block_class .= ' grid-sizer';
        }
        ?>
            <?php 
        get_template_part('content', get_post_format());
        ?>
        <?php 
    }
    ?>
        <?php 
    dw_paging_nav();
    ?>
    </div>
    <?php 
Пример #2
0
 function dw_get_next_posts()
 {
     if (!isset($_REQUEST['query_vars'])) {
         wp_send_json_error(array('message' => __('Missing query var', 'dw')));
     }
     wp_parse_str($_REQUEST['query_vars'], $query_vars);
     //get paged
     $paged = !isset($_REQUEST['paged']) || (int) $_REQUEST['paged'] <= 1 ? 1 : (int) $_REQUEST['paged'];
     $query_vars['paged'] = $paged + 1;
     query_posts($query_vars);
     if (have_posts()) {
         ob_start();
         global $block_class;
         $first = true;
         while (have_posts()) {
             the_post();
             $block_class = 'block';
             if (dw_is_featured_post()) {
                 $block_class .= ' w2';
             }
             if ($first && !dw_is_featured_post()) {
                 $first = false;
                 $block_class .= ' grid-sizer';
             }
             get_template_part('content', get_post_format());
         }
         $content = ob_get_contents();
         ob_end_clean();
         wp_send_json_success(array('html' => $content, 'query' => $_REQUEST['query_vars'], 'paged' => $paged + 1));
     } else {
         wp_send_json_error(array('code' => 'empty', 'message' => __('Reach over the content', 'dw')));
     }
     wp_reset_query();
 }