1. Home
  2. Docs
  3. Front Page (page-home.php)
  4. Latest Insights
  5. Latest Insights Scripts

Latest Insights Scripts

<?php
                              $args = array(
                                  'post_status' => 'publish',
                                  'order' => 'DESC',
                                  'orderby' => 'date',
                                  'posts_per_page' => 6
                                  );
                              $query = null;
                              $query = new WP_Query($args);

                              $count_posts = wp_count_posts();


                          ?>
                        <?php if( $query->have_posts() ) : ?>
                            <?php while ($query->have_posts()) : $query->the_post(); ?>
                    <article class="col-md-6 col-lg-4 isotopeItem <?php 
                            $cats = get_the_category();
                            if ($cats) {
                                foreach($cats as $cat) {
                                  echo strtolower(str_replace(' ','-',$cat->cat_name)); 
                                }
                              }
                           ?>">
                      <a href="<?php the_permalink($main_id); ?>">
                        <?php 
                            $cats = get_the_category();
                            if ($cats) {
                                foreach($cats as $cat) {
						?>
                                  <?php 
									$cat_type = strtolower(str_replace(' ','-',$cat->cat_name)); 
									 switch ($cat_type) {
										 case "infographics":
								?>
						  				<div class="insight-img imgLiquidFill">
                        <?php 
                       $image = get_field('insight_image_thumbnail');
                       if( !empty($image) ){
                    ?>
                      <img class="" src="<?php echo $image; ?>" alt="<?php echo get_field('insight_image_thumbnail'); ?>">
                    <?php }else{ ?>
										  <?php echo the_content(); ?>
                      <?php } ?>
										</div>
						  			<?php
										  break;
										 case "videos":
									?>
						  				<div class="insight-img imgLiquidFill">
										  <img src="http://i3.ytimg.com/vi/<?php the_field('youtube_video_id'); ?>/hqdefault.jpg" alt="ALT"  class="box-shadow">
											<div class="video-emblem"></div>
										</div>
						  			<?php
											 break;
										 default:	 
									?>
						  			<div class="insight-img imgLiquidFill">
									  <?php 
                       $image = get_field('insight_image_thumbnail');
                       if( !empty($image) ){
                    ?>
                      <img class="" src="<?php echo $image; ?>" alt="<?php echo get_field('insight_image_thumbnail'); ?>">
                    <?php }else{ ?>
                        <img src="<?php echo the_post_thumbnail_url(); ?>" alt="ALT"  class="box-shadow">
                    <?php } ?>
									</div>
						  <?php
											 break;
									 } //end switch
                                }
                              }
                           ?>  
                        <div class="blog-grid-items">
                          <!-- <ul class="blog-tags">
                            <li>cloud</li>
                            <li>technology</li>
                            <li>news</li>
                          </ul> -->
                          <span class="blog-tags">
                            <?php 
                             $posttags = get_the_tags();
                              if ($posttags) {
                                foreach($posttags as $tag) {
                                  echo $tag->name . ' | '; 
                                }
                              }
                              //echo get_the_tag_list('<p class="blog-tags">',' | ','</p>');
                            ?>
                          </span>
                             
                          
                         
                          <span class="blog-parent-cat">
                            <?php 
                            $cats = get_the_category();
                            if ($cats) {
                                foreach($cats as $cat) {
                                  echo $cat->name; 
                                }
                              }
                           ?>
                          </span>  
                          <span class="blog-titles"><?php echo get_the_title($main_id); ?> 
                          <span class="read-more">[read more]</span>
                          <span class="blog-publisher"><?php echo get_the_date($main_id);?>, <?php echo nl2br(get_field('insight_author')); ?></span>
                        </div>
                      </a>
                    </article>
                        <?php $counter++; ?>
                    <?php endwhile; ?>
                  <?php endif; wp_reset_query(); ?>
                  <!-- end loop -->    

description:

Display six of the latest posts

Was this article helpful to you? Yes No

How can we help?

Leave a Reply

Your email address will not be published. Required fields are marked *