当我试图在while循环的每个循环中拉动两个立柱时,如何将指针向前移动一个位置,或者至少偏移它?我已经指出了我想在循环中移动指针的位置:
$num_featured_max = 8;
$meta_query = WC()->query->get_meta_query();
$meta_query[] = array(
\'key\' => \'_featured\',
\'value\' => \'yes\'
);
$args = array(
\'post_type\' => \'product\',
\'meta_query\' => $meta_query,
\'orderby\' => \'date\',
\'order\' => \'ASC\',
\'posts_per_page\' => $num_featured_max
);
$the_query = new WP_Query( $args );
$the_query->found_posts = $num_featured;
$i = 1;
if ( $the_query->have_posts( ) )
{
while ( $the_query->have_posts( ) )
{
$key = \'featured-image\';
$the_query->the_post( );
$id = get_the_ID( );
$image_id = get_post_thumbnail_id( );
$background_image = wp_get_attachment_url( $image_id );
$category_id = get_the_terms( $post->ID, \'on-draught\' );
$title = get_the_title();
$section_id = strtolower( $title );
$url = get_post_meta($post->ID, $key, true);
?>
<div class="item <?php if($i <= 1){ echo \'active\';}else{ echo \'not-active\'; }?>">
<div class="row">
<a href="<?php the_permalink(); ?>" id="men" class="col-xs-6 smooth" style="background-image:url(<?php echo $url ?>)">
<div class="overlay">
<h1 class="valign"><?php echo $title;?></h1>
</div>
</a>
<!-- Trying to Move the Pointer to the next one at this point -->
<a href="<?php the_permalink(); ?>" id="women" class="col-xs-6 smooth" style="background-image:url(<?php echo $url ?>)">
<div class="overlay">
<h1 class="valign"><?php echo $title; ?></h1>
</div>
</a>
</div>
</div>
<?php
$i++;
}
}
有什么想法吗?我试过使用
->nextpost()
, 但这并没有奏效,甚至被贬值了。
以防万一,这里是my website; 我正在处理顶部的滑块。