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 8517091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:36:22+00:00 2026-06-11T05:36:22+00:00

In my WordPress post page, I have added a second loop that displays related

  • 0

In my WordPress post page, I have added a second loop that displays related posts. This loop is inside the main loop that shows the content of the post. The problem is that the addition of the second loop is messing up everything on the page.

The comments are from a different post, and making a new comment makes you jump to a different page and so on.

Obviously, I have not inserted the second loop correctly in the main loop.

Here is my code:

<div id="entries">

    <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
        <div class="entry post postpage clearfix">
            <?php if (get_option('aggregate_integration_single_top') <> '' && get_option('aggregate_integrate_singletop_enable') == 'on') echo(get_option('aggregate_integration_single_top')); ?>

            <h1 class="title"><?php the_title(); ?></h1>

            <?php get_template_part('includes/postinfo','single'); ?>

            <?php the_content(); ?>



<!-- START SECOND LOOP -->
<div class="radarcont">

<?php
$category = get_the_category();
$current_category = $category[0]->term_id;
$qarr = array(
    'showposts' => '4',
    'cat' => $current_category,
    'tag' => 'pinned', // filtered tag
    'post__not_in' => array(get_the_ID())
);
$q = new WP_Query($qarr);
if($q->have_posts()) : while ($q->have_posts()) : $q->the_post();
    ?>
<div class="singleradar clearfix">
    <?php
    $thumb = '';
    $width = 130;
    $height = 75;
    $classtext = 'post-image';
    $titletext = get_the_title();
    $thumbnail = get_thumbnail($width,$height,$classtext,$titletext,$titletext,false,'Recent');
    $thumb = $thumbnail["thumb"];
    ?>

    <?php if($thumb <> '' && get_option('aggregate_thumbnails_index') == 'on') { ?>
    <div class="thumb">
        <a href="<?php the_permalink(); ?>">
            <?php print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext, $width, $height, $classtext); ?>
            <span class="overlaymed"></span>
        </a>
    </div>  <!-- end .post-thumbnail -->
    <?php } ?>

    <h3 class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
</div> <!-- end .block-post -->

<?php endwhile; endif;?>

</div> <!-- end .radarcont -->
<!-- END SECOND LOOP -->



        </div> <!-- end .entry -->          

        <?php if (get_option('aggregate_show_postcomments') == 'on') comments_template('', true); ?>

    <?php endwhile; // end of the loop. ?>

How can I fix this? How can I adjust the second loop so that it does not mess up the rest?

  • 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-11T05:36:24+00:00Added an answer on June 11, 2026 at 5:36 am

    After looping through the second loop, you must reset your post data with:

    wp_reset_postdata();
    

    More info on: http://codex.wordpress.org/Function_Reference/wp_reset_postdata

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

Sidebar

Related Questions

I have a page template in wordpress that only shows posts from a specific
I have this in my wordpress post loop: function newWindow(uri,width,height) { if(!window.open(uri,uri,'scrollbars=1,toolbar=0,resizable=1,status=0,width='+width+',height='+height)) { document.location.href=uri;
http://demo.thethemefoundry.com/traction/#post-183 Which wordpress plugin is this, to have post image on the left side
I have a wordpress site that I only want to allow people to post
I've just followed this example from Wordpress and I have successfully added an extra
I have a tinyMCE plugin (for the post/page editor) that I am loading from
I have a standard HTML form on a WordPress post that the visitor will
I have a small problem on a wordpress custom post type page, whereby the
http://lakers.sonikastudios.com/gallery/sample-gallery-post-1/ That post has several pages using the quicktag of Wordpress. This post is
I have a self-hosted WordPress blog post that got popular and has over 100

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.