WordPress の投稿ページに、関連する投稿を表示する 2 番目のループを追加しました。このループは、投稿のコンテンツを表示するメイン ループ内にあります。問題は、2 番目のループを追加すると、ページ上のすべてが台無しになることです。
コメントは別の投稿からのものであり、新しいコメントを作成すると、別のページにジャンプしたりします。
明らかに、2 番目のループをメイン ループに正しく挿入していません。
これが私のコードです:
<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. ?>
どうすればこれを修正できますか? 残りのループを台無しにしないように、2 番目のループを調整するにはどうすればよいですか?