• Resolved 319

    (@noyz319)


    Hi, i can’t figure out how to use Kaf’s Post Image Plugin with multiple loops. I’m trying to use it in my archives to display the 6 newest in category like this:

    thumb thumb thumb
    title title title

    thumb thumb thumb
    title title title

    To format the divs into 2 rows properly i need to have 2 loops to display 3 posts each (so i can put a clear:both call in between rows). I can get the first row of three to display perfectly. The second row works somewhat, in that the title and permalinks all are correct, but the post-image plugin displays the default image instead of the actual thumbnail for the post.

    Any help would be extremely appreciated.

    Here is my code for the two loops:


    <?php
    $posts = query_posts($query_string .
    '&order=desc&posts_per_page=3');
    ?>
    <?php while (have_posts()) : the_post(); ?>
    <div id="theblock">
    <strong><div class="picbox"><a href="<?php the_permalink(); ?>"><img src="<?php post_image('https://default.com/imagelink.jpg', true, false); ?>" alt="<?php the_title(); ?>"/></a></div>
    <a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></strong>
    <small><?php the_time('F j, Y'); ?></small>
    </div>
    <?php endwhile; ?>


    <br class="clearboth" />
    <?php rewind_posts(); ?>


    <?php
    $posts = query_posts($query_string .
    '&order=desc&posts_per_page=3&offset=3');
    ?>
    <?php while (have_posts()) : the_post(); ?>
    <div id="theblock">
    <strong><div class="picbox"><a href="<?php the_permalink(); ?>"><img src="<?php post_image('https://default.com/imagelink.jpg', true, false); ?>" alt="<?php the_title(); ?>"/></a></div>
    <a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></strong>
    <small><?php the_time('F j, Y'); ?></small>
    </div>
    <?php endwhile; ?>

    Thank You!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter 319

    (@noyz319)

    As a temporary fix, i’ve found that if i change the query_post line to include a cat ID then both rows display the thumbnails correctly. Like this:


    <?php
    query_posts('cat=18&order=desc&posts_per_page=3');
    ?>


    <?php
    query_posts('cat=18&order=desc&posts_per_page=3&offset=3');
    ?>

    This solution would mean i’d need to create a seperate category template for every category on the site. I’m sure there must be a simpler way, i just can’t figure it out. If anybody has any suggestions it would really help me out. Thanks!

    Thread Starter 319

    (@noyz319)

    Nevermind, i figured it out myself. What i ended up doing was creating a variable and assigning it the value of single_cat_title.

    <?php $categoryvariable = single_cat_title("", FALSE); ?>
    <?php $categoryvariable = $cat; ?>

    And then for my two query strings i used:

    $query= 'cat=' . $categoryvariable. '&posts_per_page=3';
    query_posts($query);

    and

    $query= 'cat=' . $categoryvariable. '&posts_per_page=3&offset=3';
    query_posts($query);

    I’ll look at what the problem is in the plugin with your original queries, but could you detail what defines the value for $query_string?

    Hey!

    I am trying to do the same thing, however my knowledge in PHP is non-existent. Could you please explain more in details how you got it to work, I would extremely appreciate it since I am stuck at the same stage as you in the first post.

    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Post Image Plugin and Multiple Loops’ is closed to new replies.