views:

304

answers:

2

i am trying to build up a single.php page. this page is used to show a full single post.

i have 3 loops on it. first two are used (each) for geting a random post from a specific category.

1

<?php query_posts(array('orderby' => 'rand', 'category_name' => announcement, 'showposts' => 1)); if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; ?>
<?php endif; ?>

2

<?php query_posts(array('orderby' => 'rand', 'category_name' => quote, 'showposts' => 1)); if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; ?>
<?php endif; ?>

the problem is with the third loop that should display the REAL post itself.

3

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; else: ?>
<?php endif; ?>

^^ this displays the same post as #2.

so, #1 and #2 work great, but how to get the #3 to display the single post that it is supposed to - for example from link http://example.com/one-post/ the post titled one-post should be displayed.

#1 and #2 are in the 'top' area of the page and #3 should be in the middle of the page.

+2  A: 

fixed.

fixed it. changed #1 and #2 to

<?php
    $randomAnnouncement = new WP_Query();
    $randomAnnouncement->query('cat=545&showposts=1&orderby=rand');
    while ($randomAnnouncement->have_posts()) : $randomAnnouncement->the_post();
?>

<?php the_content(); ?>

<?php endwhile; ?>

and

<?php
    $randomQuote = new WP_Query();
    $randomQuote->query('cat=546&showposts=1&orderby=rand');
    while ($randomQuote->have_posts()) : $randomQuote->the_post(); ?>

<?php the_content(); ?>

<?php endwhile; ?>

and #3 remained as is.

hope this helps someone else.

b0x0rz
A: 

Yes it did! Thank-you.

Gil