希望这里有人能帮上忙。
理想情况下,我希望从“特色俱乐部”类别中获得一篇特色帖子,以显示来自同一自定义帖子类型的以上三篇帖子。我已经完成了以下工作,但对于其中一个,我使用了两个循环,我确信其中一个可以工作,还有两个,全幅特色帖子下的结果,显示在一列中,我需要它们排成一行。
此外,我还有另一个自定义帖子类型,我想在同一页面上的这个块下显示,还有另一个“特色类别”,按照我的方式,我将以四个循环结束。
期待得到一些帮助。
代码如下:
<h2 class="home-title">Jazz Clubs</h2>
<?php
$args = array (
\'post_type\' => \'jazz clubs\',
\'meta_query\' => array(
array(
\'key\' => \'_jazz_club_feature_club\',
),
),
);
// The Query
$jazzclubs = new WP_Query( $args );
// The Loop
if ( $jazzclubs->have_posts() ) {
while ( $jazzclubs->have_posts() ) {
$jazzclubs->the_post();
?>
<h3><?php the_title() ?></h3>
<?php the_post_thumbnail() ?>
<div class=\'post-content\'><?php the_excerpt() ?></div>
<?php
}
} else {
// no posts found
}
wp_reset_postdata();
?>
</div>
</div>
<div class="row">
<div class="small-12 large-4 columns" id="home-club">
<?php
// WP_Query arguments
$args = array (
\'post_type\' => \'jazz clubs\',
\'orderby\' => \'date\',
);
// The Query
$jazzclubs = new WP_Query( $args );
// The Loop
if ( $jazzclubs->have_posts() ) {
while ( $jazzclubs->have_posts() ) {
$jazzclubs->the_post();
?>
<div id="homeclub">
<div class="homethumb">
<?php the_post_thumbnail() ?>
<h5 id="city"class="h5"><span><?php $terms = get_the_terms( $post->ID , \'city\' );
if ( $terms != null ){
foreach( $terms as $term ) {
print $term->name ;
unset($term);
} }
?></span></h5>
</div>
<h4 id="home"class="h4"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
<h6 id="home"class="h6"><?php the_date(\'F j Y\'); ?></h6>
<div class=\'post-content\'><?php the_excerpt() ?></div>
</div>
<?php
}
} else {
// no posts found
}
// Restore original Post Data
wp_reset_postdata();
?>
</div>