Previous Video: https://youtu.be/x3HVk2PuUSA
Previous Text: http://1wmedia.blogspot.in/2016/06/listing-blog-posts-in-different-style.html
In this tutorial, We will correct the previous bugs in the code and displaying limited post lists, I mean 5 or 7 latest posts. Please view the previous tutorial before reading this tutorial.
<!-- START THE FEATURETTES -->
<?php if (have_posts()) : ?>
<?php $count = 0; ?>
<?php while (have_posts()) : the_post(); ?>
<?php $count++; ?>
<?php if ($count <= 7) : ?>
<?php if ($count % 2 == 0) : ?>
<div class="row featurette">
<div class="col-md-7">
<h2 class="featurette-heading"><?php the_title(); ?></span></h2>
<p class="lead"><?php the_content(); ?></p>
</div>
<div class="col-md-5">
<?php the_post_thumbnail('', array('class' => 'featurette-image img-responsive center-block')); ?>
</div>
</div>
<?php else : ?>
<hr class="featurette-divider">
<div class="row featurette">
<div class="col-md-7 col-md-push-5">
<h2 class="featurette-heading"><?php the_title(); ?></span></h2>
<p class="lead"><?php the_content(); ?></p>
</div>
<div class="col-md-5 col-md-pull-7">
<?php the_post_thumbnail('', array('class' => 'featurette-image img-responsive center-block')); ?>
</div>
</div>
<hr class="featurette-divider">
<?php endif; ?>
<?php endif; ?>
<?php endwhile; ?>
<?php endif; ?>
<!-- /END THE FEATURETTES -->
Video Tutorial:
Previous Text: http://1wmedia.blogspot.in/2016/06/listing-blog-posts-in-different-style.html
In this tutorial, We will correct the previous bugs in the code and displaying limited post lists, I mean 5 or 7 latest posts. Please view the previous tutorial before reading this tutorial.
- Open your front-page.php file and remove the unwanted <hr> tags.
- Add if statement for count which is the post count less than or equal to 5.
<?php if ($count <= 5) : ?> - close the if statement before the endwhile.
- Save the file. Now view the site. You will see only 5 posts in the post area.
- For Post Thumbnail, Go to Post Edit and add thumbnail. For thumbnail size, Please view the previous tutorial.
<!-- START THE FEATURETTES -->
<?php if (have_posts()) : ?>
<?php $count = 0; ?>
<?php while (have_posts()) : the_post(); ?>
<?php $count++; ?>
<?php if ($count <= 7) : ?>
<?php if ($count % 2 == 0) : ?>
<div class="row featurette">
<div class="col-md-7">
<h2 class="featurette-heading"><?php the_title(); ?></span></h2>
<p class="lead"><?php the_content(); ?></p>
</div>
<div class="col-md-5">
<?php the_post_thumbnail('', array('class' => 'featurette-image img-responsive center-block')); ?>
</div>
</div>
<?php else : ?>
<hr class="featurette-divider">
<div class="row featurette">
<div class="col-md-7 col-md-push-5">
<h2 class="featurette-heading"><?php the_title(); ?></span></h2>
<p class="lead"><?php the_content(); ?></p>
</div>
<div class="col-md-5 col-md-pull-7">
<?php the_post_thumbnail('', array('class' => 'featurette-image img-responsive center-block')); ?>
</div>
</div>
<hr class="featurette-divider">
<?php endif; ?>
<?php endif; ?>
<?php endwhile; ?>
<?php endif; ?>
<!-- /END THE FEATURETTES -->
Video Tutorial:
No comments:
Post a Comment