I am trying to filter posts from category.
This category is called "images"
And I have the code below:
<div id="owl-images" class="owl-carousel"> <?php query_posts('category_name=images'); ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <?php $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array( 5600,1000 ), false, '' );?> <a href='<?php echo $src; ?>' data-lightbox="image-77" data-title="<?php the_title() ?>"> <div class="item"> <div class="lazyOwl" style="background:url(<?php echo $src; ?>) no-repeat center center;background-size:cover;height:300px;" alt=""></div> </div> </a> <?php endwhile; endif; ?> </div>
It is inserting all the images attached as a background. It is working but not properly. Sometimes posts that aren't in the 'images' category are displayed so I guess there is something wrong but I don't know much of Wordpress development.