I have this PHP WordPress Loop which is getting articles from a tag
<?php // Fetch all posts relating to a certain tag then display 4 of them $args = array('numberposts' => 4, 'tag_slug__and' => array('tomb-raider')); $postslist = get_posts( $args ); foreach ($postslist as $post) : setup_postdata($post); ?> <?php //Get the Thumbnail URL $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array( 720,405 ), false, '' ); ?> <li class="promo-list-item" style="background-image: url(' <?php echo $src[0];?> '); background-repeat: no-repeat; background-size: cover;"> </li> <?php endforeach ?>
For some reason having this on the webpages causes all the other PHP below it to stop working. Removing this code makes the other PHP work again.
Also do you know a way of getting using a tag attached to a post as the tag to search for in the tag-slug array? Trying to get it more dynamic than having to manually enter a tag slug.
Advertisement
Answer
Fixed:
Just for others that might have the same issue.
I forgot to reset the post data using this at the end of the loop after the .