Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 384865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T15:25:20+00:00 2026-05-12T15:25:20+00:00

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

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T15:25:20+00:00Added an answer on May 12, 2026 at 3:25 pm

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to build a single page web based application, so the entire UI
I've been trying to build my first rails app and have gotten stuck on
Here's what I'm trying to do: A single build script That script builds two
We are trying to build a cross-domain single-sign on solution using ASP.NET MVC. Any
I'm trying to build application that use single config passed by server as non
I am trying to build up a single PDF from a bunch of other
I'm trying to build modal windows on the fly from single javascript object passed
I am trying to build a nice PHP framework for personal use. I realize
I'm trying to build a website where all the 'pages' are in a single
I'm trying to build a helper method to turn the two line list to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.