• My site needs 4 individual posts on the front page. Each post is in its own “column”. I want to be able to control which posts are in each column by changing the $postid. I have created a widget to do all of this, my problem is solely in getting the posts I want due to the way the “loop” works. Here is my html for one of the columns to illustrate what I am trying to do. Each column is the same as this, I was just trying to change the $postid in the respective column to the post I wanted displayed there:

    <?php query_posts( 'p=$postid' );
    // the Loop
    while (have_posts()) : the_post();?>
    <div class="subFeature-thumb" >
    <img src="<?php echo get_stylesheet_directory_uri() ?>/scripts/timthumb.php?src=<?php echo PostThumbURL(); ?>&w=220&h=100&zc=1" alt="image" />
    </div>
    <div class="subFeature-link">
    <h3><a href="<?php the_permalink() ?>" title="Continue Reading <?php the_title(); ?>"><?php the_title(); ?></a></h3>
    </div>
    <div class="subFeature-byline">
    by <?php the_author() ?> on <?php the_date() ?>
    </div>
    <div class="subFeature-text">
    <?php arc_excerpt('arc_excerptlength_subFeature', 'arc_excerptmore'); ?>
    </div>
     <?php endwhile; ?>

    Any help is greatly appreciated.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Try removing the quotes <?php query_posts( ‘p=$postid’ );

    or if that doesnt work try <?php query_posts( ‘p=”.$postid.”‘ );

    Thread Starter slamman

    (@slamman)

    Thanks for your suggestion, but it doesn’t work. I think I see where you are going and I think it is the right track. Initially I thought there was a problem in the way I was using the loop, but thanks to your suggestion and further testing I believe there is a problem with passing the variable in this part:

    <?php query_posts( ‘p=$postid’ );

    My code is working and I am getting a post…or more correctly every post.

    Prior to inserting the complete code I tested the rest of the code to make sure the variable was available by running this:

    echo $postid;

    This worked resulting in: 42

    This broke the widget:
    <?php query_posts( p=$postid );

    This resulted in no change to the original:
    <?php query_posts( ‘p=”.$postid.”‘ );

    Thread Starter slamman

    (@slamman)

    Ok I figured this out. I changed the line in question to:

    query_posts( ‘p=’. $postid );

    makes perfect sense now that I think about about it.

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

The topic ‘Help! Multiple Loops.’ is closed to new replies.