Home > OS >  WordPress content layout with Bootstrap
WordPress content layout with Bootstrap

Time:04-28

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 >
  <?php query_posts('showposts=3&orderby=date&cat=1'); ?>
  <?php while (have_posts()) : the_post(); ?>
  <div >
  <div >
  
      <img src=""  alt="...">
  </div>
  <div >
      <img src=""  alt="...">
      <img src=""  alt="...">
  </div>
  </div>
   <?php endwhile; ?>
  </div>

what i want to do

CodePudding user response:

     <div >
      <div >
      <?php $i = 1; query_posts('showposts=3&orderby=date&cat=1'); ?>
        <div >
      <?php while (have_posts()) : the_post(); ?>
        <?php if($i==1){ ?>
          <img src=""  alt="...">
        </div>
        <div >
        <?php } elseif($i==2){ ?>
          <img src=""  alt="...">
        <?php } else { ?>
        <img src=""  alt="...">
      <?php } $i  ; endwhile; ?>
        </div>
      </div>
    </div>

CodePudding user response:

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.

  • Related