• Resolved enqis

    (@enqis)


    Hello
    Is it possible to display featured images for posts from specific category ? I need to place them into a div tag but not more than 8. If there is more than 8 i need to put them into next div and so on and so on.
    Could somebody give some tip how to do this ? Any advice appriciate.

    Regards

Viewing 2 replies - 1 through 2 (of 2 total)
  • You may use something like this

    <?php
    query_posts( array( 'category__and' => array(1,3), 'posts_per_page' => 2) );
    if (have_posts()) : while (have_posts()) : the_post();
    $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array( 1680,470 ), false, '' );
    ?>
    <div id="header-hero" style="background-image: url('<?php echo $src[0]; ?>');">
    // Put your 8 logic here
    <?php endwhile; endif; ?>
    <?php wp_reset_query(); ?>
    Thread Starter enqis

    (@enqis)

    <?php
          query_posts('cat=8');
          $postCount = 0;
          while (have_posts()) : the_post();
          if ($postCount==0) {echo "<div class='wrapper'>";};
          echo "<a href='#' class='featured-img'>";
          the_post_thumbnail();
          echo "</a>";
          $postCount++;
          if ($postCount==8) {echo "</div>"; $postCount=0;};
          endwhile;
          if ($postCount<8 || $postCount>0) {echo "</div>";};
          echo $postCount;
    ?>

    I have written something like this. It works well however query show only 10 posts and it ends. How to solve this and make query show all posts in category.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Paged featured images’ is closed to new replies.