query_posts and post_parent -> not working (3 posts)

  1. bellemode
    Posted 2 years ago #

    On my home page of the site I'm working on (which uses home.php) I want to display content from different pages from parent with id of 96 and 101, and the title of the pages.

    With this in mind I used

    <div id="about">
    		<?php query_posts('posts_per_page=1&post_type=page&post_parent=96'); the_post(); ?>
    		<h1><?php the_title(); ?></h1>
    		<?php the_content(); ?>

    It seemed to work at first and I was excited. Then I placed another query on the page

    <div class="information">
    <?php query_posts('posts_per_page=1&post_type=page&post_parent=101'); the_post(); ?>
    <h2><?php the_title(); ?></h2>
    <div class="underline"><img src="<?php echo bloginfo('template_url'); ?>/images/underline.png" width="90" height="8" alt="underline"></div>
    <?php the_content(); ?>

    Then both areas were displaying the parent 101 data. Then I refreshed and it won't display any data in those divs.

    I tried isolating it by taking out &post_parent=96 When I do that it goes back to posting the most recent page created. I don't understand why it won't pull in the id I'm asking for.

  2. egado
    Posted 2 years ago #

    Guess you need to reset the query :)

    Please have a look at http://codex.wordpress.org/Function_Reference/wp_reset_query and let us know if it helps :)

  3. bellemode
    Posted 2 years ago #

    Thanks for the help egado, but that didn't work either. I ended up using Advanced Custom Fields.

Topic Closed

This topic has been closed to new replies.

About this Topic