我试图通过自定义帖子将HTML滑块转换为wordpress。这是滑块的HTML标记
<div class="slider">
<div class="slide_item">
<div class="child_item_of_every_slide">Child Slide Items with different Content</div>
<div class="child_item_of_every_slide">Child Slide Items with different Content</div>
<div class="child_item_of_every_slide">Child Slide Items with different Content</div>
<div class="child_item_of_every_slide">Child Slide Items with different Content</div>
</div>
<div class="slide_item">
<div class="child_item_of_every_slide">Child Slide Items with different Content</div>
<div class="child_item_of_every_slide">Child Slide Items with different Content</div>
<div class="child_item_of_every_slide">Child Slide Items with different Content</div>
<div class="child_item_of_every_slide">Child Slide Items with different Content</div>
</div>
<div class="slide_item">
<div class="child_item_of_every_slide">Child Slide Items with different Content</div>
<div class="child_item_of_every_slide">Child Slide Items with different Content</div>
<div class="child_item_of_every_slide">Child Slide Items with different Content</div>
<div class="child_item_of_every_slide">Child Slide Items with different Content</div>
</div>
</div>
之前我使用自定义帖子转换了许多滑块,但这个滑块标记对我来说很复杂,并且无法理解如何将此滑块转换为wordpress。
Please see this screenshot,这很容易理解。
通常我使用以下查询来转换滑块。请通过给我自定义的帖子查询代码来转换上面的滑块来帮助我。提前谢谢!对所有人来说。
`<?php if(!is_paged()) { ?>
<?php
$args = array( 'post_type' => 'slider', 'posts_per_page' => 5 );
$loop = new WP_Query( $args );
?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div class="slide_item">
<div class="child_item_of_every_slide">Child Slide Items with different Content</div>
</div>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
<?php } ?>`
答案 0 :(得分:1)
<?php if(!is_paged()) { ?>
<?php
$args = array( 'post_type' => 'slider', 'posts_per_page' => 5 );
$loop = new WP_Query( $args );
$count=1;
?>
<div class="slider">
<div class="slide_item">
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div class="child_item_of_every_slide">Child Slide Items with different Content</div>
<?php
if($count%4==1&&$count>1){
echo '</div><div class="slide_item">';
}
$count++;
?>
<?php endwhile; ?>
</div>
</div>
<?php wp_reset_query(); ?>
<?php } ?>