Wordpress posts loop help

Status
Not open for further replies.

figment

New Member
Hi guys,
I am putting together a single page collecting together all the posts from a category:
GAAQuotes - Sheepstealers GAA Clothing & T-Shirts

If i move the page content code below the category content code it takes on the category ID and starts to display all the posts from the category instead of just the content for this page.

How can I change the code of the first loop so that it only displays that pages content no matter where in the page i put it?

Or even better, how can i split it up so i display the page content above the category content and display the comments below the category content.

Hope that makes sense.
Alan

Code:
<!--START OF CONTENT FROM PAGE ITSELF -->
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php the_title(); ?>
<?php the_content(); ?>
<?php comments_template(); ?>
<?php endwhile; endif; ?>
<!--END OF CONTENT FROM PAGE ITSELF -->

<!--START OF CONTENT FROM CATEGORY -->
<?php query_posts('cat=51'); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

<div class="gaaquote">
<div class="shadowtop"></div>
<?php if ( function_exists('jr_post_image') ) { jr_post_image($id); } ?>
<a href="<?php the_permalink()?>"><?php if ( has_post_thumbnail() ) {
    the_post_thumbnail( array(200,200) );
} ?></a>
<!--<?php the_excerpt(); ?> -->
<div class="shadowbottom"></div>
</div>

<?php endwhile; endif; ?>
<!--END OF CONTENT FROM CATEGORY -->
 

figment

New Member
For anyone else looking in future:
I used WP Query instead Class Reference/WP Query « WordPress Codex

Code:
<!--START OF THIS PAGE CONTENT -->
<?php

// The Query
$the_query = new WP_Query('page_id=1580');

// The Loop
while ( $the_query->have_posts() ) : $the_query->the_post();
    the_title();
    the_content();
endwhile;

// Reset Post Data
wp_reset_postdata();

?>

<!--END OF THIS PAGE CONTENT -->

<!--START OF THIS CATEGORY POSTS -->
<?php

// The Query
$the_query = new WP_Query( 'cat=51' );

// The Loop
while ( $the_query->have_posts() ) : $the_query->the_post();

    echo '<div class="gaaquote">';
    echo '<div class="shadowtop"></div>';
    echo '<a href="'; 
    the_permalink(); 
    echo '">';
    the_post_thumbnail( array(200,200) );
    echo '</a>';
    echo '<div class="shadowbottom"></div>';
    echo '</div>';
    
endwhile;

// Reset Post Data
wp_reset_postdata();

?>
<!--END OF THIS CATEGORY POSTS -->

<div class="clearall"></div>

<!--START OF THIS PAGE COMMENTS -->
<?php

// The Query
$the_query = new WP_Query('page_id=1580');

// The Loop
while ( $the_query->have_posts() ) : $the_query->the_post();
    comments_template(); 
endwhile;

// Reset Post Data
wp_reset_postdata();

?>

<!--SEND OF THIS PAGE COMMENTS -->
 
Status
Not open for further replies.
Top