please help me with this annoying issue as i'm junior in wordpress , i have a different slider in my project and i made a custom post type to make attachment posts on in to make every single post as a slider .. the problem is how to loop inside CPT to retrieve every single post when i want is to display on front-end i tried alot and searched on net about it but the only code that i found and i used it made every single post to override the first post .. this is my code
<?php
$query = new WP_Query( array(
'post_type' => 'owlgalleryslider',
'posts_per_page'=> 3,
'fields' => 'ids'
));
$image_query = new WP_Query(array(
'post_type' => 'attachment',
'post_status' => 'puplish',
'post_mime_type' => 'image',
'posts_per_page' => 3,
'post_parent' => $query->id,
'order' => 'DESC'
));
?>
<?php if( have_posts( )) : ?>
<?php while ($image_query->have_posts()) : $image_query->the_post( ); ?>
<div class="item owl-slide"> <img src="<?php echo wp_get_attachment_url( get_the_ID() ); ?>" /> </div>
<?php endwhile; wp_reset_query( );?>
<? endif;?>
If you want to create a slider, set the featured image for every slider post and use that image in your WP_Query loop.