0
在我的WordPress的帖子頁面中,我添加了第二個循環來顯示相關的帖子。該循環位於顯示帖子內容的主循環中。問題是增加第二個循環會搞亂頁面上的所有內容。循環裏面的第二個循環弄亂了帖子
評論來自另一篇文章,並且發表新評論讓您跳轉到其他頁面等等。
很明顯,我沒有在主循環中正確插入第二個循環。
這裏是我的代碼:
<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. ?>
我怎樣才能解決這個問題?如何調整第二個循環,以免弄亂其餘部分?
唉唉:上
更多信息!在我發佈這個問題之前,我嘗試了這個,但是我沒有正確地閱讀文檔,而是在第二個循環之前放置了重置*。儘管如此,歡呼的解決方案。 Upvoted和接受。 –