I would like a multiple look to display the_content from the current page, & from another page. My multiple loo doesn't seem to be working. Can anyone advise, please?

while( have_posts() ): the_post();

$post = get_post($id);
$title = apply_filters('the_title', $post->post_title);
echo $title;
$content = apply_filters('the_content', $post->post_content);
echo $content;

Please can someone advise? Thank-you!

  • Are you missing some code? I see endwhile; twice but while: appears only once, and there's no if: – Tom J Nowell Aug 12 '14 at 22:27
  • @TomJNowell I seem to have made it work, answer below. Please could I ask you to have a quick look and say if that's how you would do it? I would really appreciate it. Thank-you. – mattnewbie Aug 12 '14 at 22:39

This seems to work:

while( have_posts() ): the_post();

$my_query = new WP_Query('page_id=40');
while ($my_query->have_posts()) : $my_query->the_post();
    $do_not_duplicate = $post->ID;?>

        <div class="entry">

            <?php the_content('read more &raquo;'); ?>


| improve this answer | |
  • Is this how others would do this? I would really appreciate some tips for improvement. Thank-you all! – mattnewbie Aug 12 '14 at 22:40
  • 2
    I would indent everything correctly ( your editor should auto-indent for you as you type ), I'd also use the other syntax while () {} rather than while(): while; as it has wider support in editors and tools ( think brace matching ). I'd also put the call to the_post on its own line. I'm not sure why you've got the $do_not_duplicate in there. 'pageid=40' would be better as array( 'p' => 40 ) – Tom J Nowell Aug 12 '14 at 22:50
  • 1
    Also upvoted for answering your own question – Tom J Nowell Aug 12 '14 at 22:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.