skip to Main Content

I’m trying to pull wordpress content to the grid structure created with Bootstrap. But I don’t want to create separate query for each column. How can I pull content from the same category in a single query? My codes are as follows.I want to show the last 3 items added

 <div class="container">
  <?php query_posts('showposts=3&orderby=date&cat=1'); ?>
  <?php while (have_posts()) : the_post(); ?>
  <div class="row">
  <div class="col-8">
  
      <img src="" class="img-fluid rounded" alt="...">
  </div>
  <div class="col-4">
      <img src="" class="img-fluid mb-3 rounded" alt="...">
      <img src="" class="img-fluid rounded" alt="...">
  </div>
  </div>
   <?php endwhile; ?>
  </div>

what i want to do

2

Answers


  1. Chosen as BEST ANSWER

    click the picture for the problem

    else created a problem. Also the 2 contents in the right column are the same. I wanted it to be different.


  2.      <div class="container">
          <div class="row">
          <?php $i = 1; query_posts('showposts=3&orderby=date&cat=1'); ?>
            <div class="col-8">
          <?php while (have_posts()) : the_post(); ?>
            <?php if($i==1){ ?>
              <img src="" class="img-fluid rounded" alt="...">
            </div>
            <div class="col-4">
            <?php } elseif($i==2){ ?>
              <img src="" class="img-fluid mb-3 rounded" alt="...">
            <?php } else { ?>
            <img src="" class="img-fluid rounded" alt="...">
          <?php } $i++; endwhile; ?>
            </div>
          </div>
        </div>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search