【发布时间】:2016-03-17 12:54:22
【问题描述】:
我想在查询中循环查询。
这实际上应该成功:
<div class="container inner-cont">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="row">
<div class="col-md-8 column">
<?php the_content(); ?>
</div>
<div class="col-md-4">
<!-- START -->
<?php
query_posts(array(
'post_type' => 'mitarbeiter',
'showposts' => 10
) );
// Get the members
while (have_posts()) : the_post();
if (in_array($title, get_field('kompetenzen'))) :
// Display the image
$image = get_field('portraitfoto');
if (!empty($image)): ?>
<img class="sidebar-img" src="<?= $image['url']; ?>" alt="<?= $image['alt']; ?>" /><br />
<?php endif; ?>
<h2><?php the_title(); ?></h2>
<?= the_field('funktion'); ?><br>
<?= the_field('telefon'); ?><br>
<?= the_field('email'); ?><br>
<?php endif; ?>
<?php endwhile; ?>
<!-- END -->
</div>
</div>
<?php endwhile; else: ?>
<?php endif; ?>
</div>
我遇到的问题是,您在<!-- START --> 和<!--END --> 之间找到的循环无休止地运行!相同的内容会一遍又一遍地显示。为什么会发生这种情况,我该如何解决?
【问题讨论】:
标签: php wordpress loops while-loop