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

  • SEARCH
  • Home
  • 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 9162735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:16:56+00:00 2026-06-17T14:16:56+00:00

The code below should display the content of the page followed by certain page

  • 0

The code below should display the content of the page followed by certain page content.

    <!-- Section -->
    <section>
    <?php if (have_posts()): while (have_posts()) : the_post(); ?>

        <!-- Article -->
        <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

            <!-- Posts for homepage -->
            <?php
                if ( is_front_page() ) { ?>
                    <?php the_content(); ?>

                    <!-- Show page content according to page ID -->
                    <div class="title-home clearfix">
                        <div class="four title-home-text">Services Spotlight</div>
                        <div class="four title-home-text" style="margin-left: 115px;">Industry Expertise</div>
                        <div class="four title-home-text" style="margin-left: 125px;">Features &amp; Benefits</div>
                    </div>
                    <div class="four-wrapper clearfix">
                    <div class="four-container">
                        <div class="four-col line"> 
                         <?php
                            query_posts('page_id=40');
                            while (have_posts()): the_post();
                               the_content();
                            endwhile;
                        ?>
                        </div>
                        <a href="" class="read-morebtn"> read more </a>
                    </div>

                    <div class="four-container">    
                        <div class="four-col line"> 
                         <?php
                            query_posts('page_id=41');
                            while (have_posts()): the_post();
                               the_content();
                            endwhile;
                        ?>
                        </div>
                        <a href="" class="read-morebtn"> read more </a>
                    </div>

                    <div class="four-container">    
                    <div class="four-col line"> 
                     <?php
                        query_posts('page_id=42');
                        while (have_posts()): the_post();
                           the_content();
                        endwhile;
                    ?>
                    </div>
                    <a href="" class="read-morebtn"> read more </a>
                    </div>


                    <div class="four-container">    
                        <div class="four-col line"> 
                            <?php if(!function_exists('dynamic_sidebar') || !dynamic_sidebar('widget-area-3')) ?>
                        </div>
                    </div>

                    </div>


                <?php
                } 
                else {
                ?>
                    <h1><?php the_title(); ?> </h1>
                    <?php  the_content(); ?>
                <?php } ?>
            <!-- end post homepage -->




            <br class="clear">

            <?php edit_post_link(); ?>

        </article>
        <!-- /Article -->

        <?php endwhile; ?>

        <?php else: ?>

        <!-- Article -->
        <article>
            <h2><?php _e( 'Sorry, nothing to display.', 'html5blank' ); ?></h2>
        </article>
        <!-- /Article -->

    <?php endif; ?>

    </section>

    <!-- /Section -->

<?php get_footer(); ?>

However, it displays the last query as loop.

Output Code:

<article id="post-6" class="post-6 page type-page status-publish hentry">
<article id="post-42" class="post-42 page type-page status-publish hentry">

post-42 should not be displayed in the article.

Also, I know the code is not simplified for using while loop. I want to fix the article problem and simplify this code.

  • 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-06-17T14:16:58+00:00Added an answer on June 17, 2026 at 2:16 pm

    The codex advises against using query_posts for secondary loops as per Codex Query Posts Page

    It looks like you are stomping on the main loop (article) since query_posts alters the main loop. If you want to use query_posts it is recommended that you call wp_reset_query() when done. The preferred method is to use WP_query().

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

Sidebar

Related Questions

The code below takes an array value, if it's key exist it should echo
I suppose button should has Close title in the code below, but it has
Please see my pseudo-code below. The code comments should explain my problem. I'm new
The below code seems like it should work; however, the blob in the database
I'm using bootstrap to display content below tabs, but I want to collapse the
Am only looking to play some flash content on my page. found this code
I want to display some text below each grid image. Please see my code
Code below is working well as long as I have class ClassSameAssembly in same
Code below is used to save PostgreSql database backup from browser in Apache Mono
The code below simply didn't work. document.getElementById('files').addEventListener('change', handleFileSelect, false); reported by firebug that this

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.