WordPress.org

Forums

[resolved] Multiple Loops (9 posts)

  1. Danny159
    Member
    Posted 3 years ago #

    Hi,

    I have the following code in a template file (page-home.php) and I want to include bits of different pages in this file:

    I have the following code:

    [Code moderated as per the Forum Rules. The maximum number of lines of code that you can post in these forums is ten lines. Please use the pastebin]

    However the second loop doesn't work... the ID is correct it just doesnt show anything...

    Can anyone please help and spot my problem!

    Dan

  2. Danny159
    Member
    Posted 3 years ago #

    Please see the code here: http://pastebin.com/W1MPqEa0

  3. alchymyth
    Forum Moderator
    Posted 3 years ago #

    I can't see anything wrong with these near identical two blocks of code -

    apart form using query_posts() for secondary loops; better to use WP_Query() - http://codex.wordpress.org/Function_Reference/query_posts#Caveats

    have you checked the html output in the browser, to see if the second loop's output is possibly just hidden?

    what happens if you swap the page IDs between the queries?
    does the page 70 have direct children?

  4. Danny159
    Member
    Posted 3 years ago #

    Hi Thanks for you reply...

    I replaced some code and added:

    <?php
    	$the_query = new WP_Query(array('page_id' => "18", 'post_type' => 'page'));
    	while($the_query->have_posts()) : $the_query->the_post();
        ?>

    I changed the id's around and still nothing... actually nothing at all shows now except my recent posts....

    Here is my full new code: http://pastebin.com/07D6Zd9R

    Dan

    Also no pages have children yet

  5. alchymyth
    Forum Moderator
    Posted 3 years ago #

    Also no pages have children yet

    you were running queries looking for children pages....

    http://codex.wordpress.org/Class_Reference/WP_Query#Post_.26_Page_Parameters

    [edit]
    just saw the edited queries; if those pages exist, there should be some output.

    do you get at least the two empty divs?

    <div class="column_small" style="width:290px;">
    </div>

    where is that pastebin code inserted in which tempalte?

  6. Danny159
    Member
    Posted 3 years ago #

    Ahhh but even this doesnt work:

    <?php $the_query = new WP_Query('page_id=18'); ?>

    Sorry for been stupid!

  7. Danny159
    Member
    Posted 3 years ago #

    Yes I get that... :( dont know why...

    Dan

  8. Danny159
    Member
    Posted 3 years ago #

    My full template code: http://pastebin.com/DTTnWNvU

  9. Danny159
    Member
    Posted 3 years ago #

    I fix this problem... I changed $the_query to $front_query1 and $front_query2 and now it all works.

    Thanks for your help!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags