Please inspect my loop
-
Hi guys so im having some trouble was hoping another pair of eyes could help find out whats wrong here..
I have a loop that gives each post a unique div, everythings working great but for some reason the first post seems to come up as the website.. heres a screenshot of what i mean..
As you can see, for some reason its always a blank post in the loop that links to the homepage.. very annoying, here is my loop.
<div id="featured-topics"> <?php $count = 0; ?> <?php $args = array( 'posts_per_page' => 4, 'category_name' => 'news' ); $posts = get_posts( $args ); ?> <?php foreach (array_chunk($posts, 1, true) as $posts) : $count++; ?> <div class="column-<?php echo $count; ?>" style="background-image: url('<?php the_post_thumbnail_url( $size ); ?>')"> <a class="featured-<?php echo $count; ?>" href="<?php the_permalink(); ?>"> <?php foreach( $posts as $post ) : setup_postdata($post); ?> <?php endforeach; ?> </a></div> <!-- column/featured --> <?php endforeach; ?> </div>
Thanks in advance
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Please inspect my loop’ is closed to new replies.