WordPress Custom post query for slider

I’m trying to convert a HTML slider into wordpress by custom post. Here is the HTML Markup for the slider

<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>

Read More

I converted many slider using custom post before but this sliders markup is something complex to me and can’t understand How to convert this slider into wordpress.

Please see this screenshot, that will be easy to understand.

Normally I use the below query to convert slider. Please help me someone by giving me the custom post query code to convert the above slider. Advance Thanks! to all.

    `<?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 } ?>`

Related posts

Leave a Reply

1 comment

  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 } ?>