WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Post Image Plugin and Multiple Loops (5 posts)

  1. noyz319
    Member
    Posted 7 years ago #

    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('http://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('http://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!

  2. noyz319
    Member
    Posted 7 years ago #

    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!

  3. noyz319
    Member
    Posted 7 years ago #

    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);

  4. Kafkaesqui

    Posted 7 years ago #

    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?

  5. lineageescape
    Member
    Posted 7 years ago #

    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!

Topic Closed

This topic has been closed to new replies.

About this Topic