nicoliver
Member
Posted 1 month ago #
Hi,
I have created a custom page template in WP.
Within this page I have created a query that displays all posts from a specific category. What I would now like to do is place the original page content + comments at the bottom.
For some reason it is showing the titles from the previous query loop.
This is the page: http://dinky.nicholasoliver.co.uk/
I have tried a few various options like wp_reset_query and defining parameters for a new loop but none seem to work.
Does anyone have a suggestion on how I might go about stopping the first loop and then loading the pages content?
thanks
Try a variation of this.
<?php
$args=array(
'category__in' = array(7,45),
'showposts' => 5,
'caller_get_posts'=>1
);
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
echo '5 recent Posts';
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
<?php
endwhile;
} //if ($my_query)
wp_reset_query(); // Restore global post data stomped by the_post().
?>
nicoliver
Member
Posted 1 month ago #
You're a genius! Thank you so much!!
Been trying to solve this for ages.