0

I have been working on a Wordpress theme from few days. I want to achieve modern like layout in my theme's frontpage.

But I am having no clue that how to achieve it.

Now my wordpress theme loops the post in this manner

<div class="col-xs-8">
<article class="post1"></article>
<article class="post2"></article>
<article class="post3"></article>
<article class="post4"></article>
<article class="post5"></article>
</div>

What I want to achieve in the above code is

<div class="col-xs-8">

   <!-- First post Wrapper-->
   <div class="first-post">
      <article class="post1"></article>
   </div>

<!-- Rest all post Wrapper-->
   <div class="all-posts">
      <article class="post2"></article>
      <article class="post3"></article>
      <article class="post4"></article>
      <article class="post5"></article>
   </div>

</div>

Can anyone suggest a possible solution with this custom looping for a frontpage.

3
  • 2
    Please don't ask for urgent help - we all donate our time here, as and when we can. Commented Oct 9, 2015 at 9:18
  • Instead of needing urgent help, rather file an edit and explain to us what you have tried yourself and add your code and explain where you are failing. I need urgent help and showing us no effort is not going to get you any help at all. ;-) Commented Oct 9, 2015 at 11:16
  • I'm sorry for using wrong word friends. Actually it's been three days I have been trying to achieve the result I mentioned above. So you can imagine what was in my head and in that tension I asked for urgent help. Hope you may understand. Commented Oct 9, 2015 at 15:09

1 Answer 1

0

Hi I believe this should work

<div class="col-xs-8">
    <?php $count  = 1; ?>
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
       <?php if $count = 1; ?>
            <!-- First post Wrapper-->
            <div class="first-post">
              <article class="post1"></article>
            </div>

            <!-- Rest all post Wrapper-->
            <div class="all-posts">
        <?php else : ?>
                <article class="post<?php echo $count; ?>"></article>
        <?php endif; ?>
    <?php $count++; endwhile; endif; ?>
    </div>
</div>
3
  • Hi RiaanZA Thanks for your time, but it's not working with the post loop. I have tried the similar code earlier before posting this question, it didn't work with Commented Oct 9, 2015 at 14:58
  • It's not working for sticky posts? Do you know any solution so that it should work for sticky posts too?? Commented Oct 9, 2015 at 15:06
  • A lot of Thanksssssss to you RiaanZA You saved my day Commented Oct 9, 2015 at 15:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.