• hello
    i wanted to design my wordpress loop like this. i want to show 5 post of a specific category.and the design will be : first category name then first post feature img with title over img.. andother 4 post should,nt have any featured img. like this https://i.stack.imgur.com/4fEwU.jpg
    can it possible.?

    sorry about spelling..

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Try this.

    <?php
      query_posts(array( 
        'post_type' => 'post',
        'showposts' => 5
      )); 
    
      $i = 0;
      while ( have_posts() ) :
      the_post();
      $i++;
    ?>
      <a class="card" href="<?= get_permalink() ?>">
    
        <?php if ($i === 1) : ?>
          <div class="card__meta"><?= get_the_category()[0]->cat_name ?></div>
          <div class="card__media">
            <img src="<?php the_post_thumbnail_url('medium'); ?>">
          </div>
          <div class="card__title"><?php the_title(); ?></div>
        <?php else : ?>
          <div class="card__title"><?php the_title(); ?></div>
        <?php endif; ?>
    
      </a>
    <?php endwhile; ?>
    • This reply was modified 7 years, 9 months ago by bluder.
    • This reply was modified 7 years, 9 months ago by bluder.
Viewing 1 replies (of 1 total)

The topic ‘Help me out in This WordPress Loop Design’ is closed to new replies.