我有两个WP_query
在我的frontpage中循环。php文件:
<div id="aanbod">
<div class="container-fluid section-name-cont">
<div class="container">
<div class="row">
<div class="col-xs-12 section-name"><h1>Aanbod</h1></div>
</div>
</div>
</div>
<?php
$args = array(
\'post_type\' => \'vastgoedobject\',
\'meta_key\' => \'status\',
\'meta_value\' => array(\'Te Huur\', \'Binnenkort te huur\'),
\'posts_per_page\' =>-1,
);
$aanbod_query = new WP_Query( $args );
if ( have_posts() ) : while ( $aanbod_query->have_posts() ) : $aanbod_query->the_post();
?>
<div class="content-section-<?php if( $the_query->current_post%2 == 1 ){ echo \'b\';}else{ echo \'a\';} ?>">
<div class="container">
<div class="row">
<div class="col-lg-5 <?php if( $the_query->current_post%2 == 1 ){ echo \'col-lg-offset-1 col-sm-push-6 \';} ?>col-sm-6 lead-parent">
<div class="clearfix"></div>
<a href="<?php the_permalink(); ?>"><h2 class="section-heading"><?php the_field(\'straat\'); ?> <?php the_field(\'huisnummer\'); ?>, <?php the_field(\'stad\'); ?></h2></a>
<span class="label label-default"><?php the_field(\'status\'); ?></span>
<span class="label label-default"><?php echo $euro ;?><?php the_field(\'totale_huurprijs\'); ?>,-</span>
<span class="label label-default"><?php the_field(\'verdieping\'); ?></span>
<span class="label label-default"><?php the_field(\'aantal_kamers\'); ?>-kamer <?php the_field(\'beschrijving_vastgoed\'); ?></span>
<span class="label label-default"><?php the_field(\'totaaloppervlak\'); ?> <?php echo $m2 ;?></span>
<?php the_field(\'beschrijving\'); ?>
<a href="<?php the_permalink(); ?>"><button type="button" class="btn btn-default">Bekijk <?php the_field(\'beschrijving_vastgoed\'); ?></button></a>
</div>
<div class="col-lg-5 <?php if( $the_query->current_post%2 == 1 ){ echo \'col-sm-pull-6\';}else{ echo \'col-lg-offset-2\';} ?> col-sm-6">
<a href="<?php the_permalink(); ?>" class="foto-wrapper">
<?php if ( !$detect->isMobile() ) {
echo get_image_object_acf(\'img-responsive img-rounded\', \'false\', \'foto\', \'\', \'fp-aanbod\', \'glyphicon-share-alt\');
} else {
echo get_image_object_acf(\'img-responsive img-rounded\', \'false\', \'foto\', \'\', \'fp-aanbod\', \'\');
} ?>
</a>
</div>
</div>
</div>
</div>
<?php endwhile; else: ?>
<h1>Kampbeheer heeft momenteel niks te huur!</h1>
<?php
endif;
rewind_posts();
?>
<div id="onlangs-verhuurd">
<div class="container-fluid section-name-cont">
<div class="container">
<div class="row">
<div class="col-xs-12 section-name"><h1>Onlangs Verhuurd</h1></div>
</div>
</div>
</div>
<?php
$args = array(
\'post_type\' => \'vastgoedobject\',
\'meta_key\' => \'status\',
\'meta_value\' => array(\'Verhuurd\'),
\'posts_per_page\' => 4,
);
$verhuurd_query = new WP_Query( $args );
?>
<?php if ( have_posts() ) : while ( $verhuurd_query->have_posts() ) : $verhuurd_query->the_post(); ?>
<div class="content-section-<?php if( $the_query->current_post%2 == 0 ){ echo \'b\';}else{ echo \'a\';} ?>">
<div class="container">
<div class="row">
<div class="col-lg-5 <?php if( $the_query->current_post%2 == 0 ){ echo \'col-lg-offset-1 col-sm-push-6 \';} ?>col-sm-6 lead-parent">
<div class="clearfix"></div>
<h2 class="section-heading"><?php the_field(\'straat\'); ?>, <?php the_field(\'stad\'); ?></h2>
<?php if(get_field(\'totaaloppervlak\')) { ?><span class="label label-default"><?php the_field(\'totaaloppervlak\'); ?> <?php echo $m2 ;?></span><?php } ?>
<?php the_field(\'beschrijving\'); ?>
</div>
<div class="col-lg-5 <?php if( $the_query->current_post%2 == 0 ){ echo \'col-sm-pull-6\';}else{ echo \'col-lg-offset-2\';} ?> col-sm-6 foto-wrapper">
<?php echo get_image_object_acf(\'img-responsive img-rounded\', \'false\', \'foto\', \'\', \'fp-aanbod\', \'\') ?>
</div>
</div>
</div>
</div>
<?php endwhile; else: ?>
<p>Niks te weergeven hier!</p>
<?php endif; ?>
这个<?php endwhile; else: ?>
部件不工作,它只是不显示任何内容,而不是<h1>Kampbeheer heeft momenteel niks te huur!</h1>
或<p>Niks te weergeven hier!</p>
未查询帖子时
我错过了什么?