コード例 #1
0
    public static function content_posts($paged = 1)
    {
        global $wp_query, $wdwt_front, $post;
        $hide_content_posts = $wdwt_front->get_param('hide_content_posts');
        $hide_video_post = $wdwt_front->get_param('hide_video_post');
        $content_post_categories = $wdwt_front->get_param('content_post_categories', array(), array(''));
        $content_post_cat_name = $wdwt_front->get_param('content_post_cat_name');
        $blog_style = $wdwt_front->get_param('blog_style');
        $content_post_categories = implode(',', $content_post_categories);
        $cat_checked = 0;
        $grab_image = $wdwt_front->get_param('grab_image');
        $n_of_home_post = get_option('posts_per_page', 6);
        if ($hide_content_posts && $n_of_home_post != 0) {
            ?>
  <div id="content_posts_section">
    <div id="blog" class="content-inner-block">     
      <?php 
            $wp_query = new WP_Query('posts_per_page=' . $n_of_home_post . '&ignore_sticky_posts=1&cat=' . news_magazine_frontend_functions::remove_last_comma($content_post_categories) . '&paged=' . $paged . '&order=DESC');
            ?>
      <div class="blog-post">
        <h2><?php 
            echo esc_html($content_post_cat_name);
            ?>
</h2>
		<div id="blog_post">
        <ul id="list">
      <?php 
            if (have_posts()) {
                while ($wp_query->have_posts()) {
                    $wp_query->the_post();
                    $tumb_id = get_post_thumbnail_id($post->ID);
                    $thumb_url = wp_get_attachment_image_src($tumb_id, 'full');
                    $has_thumb = true;
                    if ($thumb_url) {
                        $thumb_url = $thumb_url[0];
                    } else {
                        $thumb_url = news_magazine_frontend_functions::catch_that_image();
                        if (isset($thumb_url['image_catched']) && $thumb_url['image_catched']) {
                            $has_thumb = true;
                        } else {
                            $has_thumb = false;
                        }
                        $thumb_url = $thumb_url['src'];
                    }
                    ?>
          <li>
            <div class="latest_posts <?php 
                    if ($has_thumb) {
                        echo "has_thumb";
                    }
                    ?>
">
              <?php 
                    echo news_magazine_frontend_functions::fixed_thumbnail(145, 100, $grab_image);
                    ?>
              <span class="date lat_news"><?php 
                    echo get_the_time('d M');
                    ?>
</span>
            </div>
            <h3><a href="<?php 
                    echo get_permalink();
                    ?>
"><?php 
                    the_title();
                    ?>
</a></h3></br>
            <p> <?php 
                    news_magazine_frontend_functions::the_excerpt_max_charlength(100);
                    ?>
</p>
          </li>
          <?php 
                }
            }
            ?>
        </ul>
		<div class="section_pagination">
		<?php 
            if ($paged > 1) {
                ?>
			<span class="content_posts_pagination prev_section" id="content_posts_left" onclick="wdwt_front_ajax_pagination(<?php 
                echo $paged - 1;
                ?>
, 'content_posts_section', '#content_posts_section');" ><i class="fa fa-chevron-left"></i>&nbsp;&nbsp;<b>Previous</b></span>
		<?php 
            }
            if ($paged < $wp_query->max_num_pages) {
                ?>
			<span class="content_posts_pagination next_section" id="content_posts_right" onclick="wdwt_front_ajax_pagination(<?php 
                echo $paged + 1;
                ?>
, 'content_posts_section', '#content_posts_section');"><b>Next</b>&nbsp;&nbsp;<i class="fa fa-chevron-right"></i></span>
		<?php 
            }
            ?>
		</div> 
	   </div>
      </div>       
    </div>
    <div class="clear"></div>
   </div>
    <?php 
        }
        wp_reset_query();
    }