I'm using a custom post query to pull some data from Wordpress into a slider. I then want to get the post content from the actual page that the slider is on but the post data doesn't seem to reset and pull through the original data.
If I put my second code block in <div class='main'>
above the custom slider post code then the data is pulled through.
How can I reset my post data elegantly?
<div class="banner">
<?php
//PULL THROUGH THE DATA
$type = 'slider';
$args = array(
'post_type' => $type,
'post_status' => 'publish',
'order' => 'ASC',
'posts_per_page' => -1
);
$posts = get_posts($args);
?>
<ul class="slider">
<?php foreach ($posts as $post) : setup_postdata($post); ?>
<?php
$thumb_id = get_post_thumbnail_id();
$thumb_url_array = wp_get_attachment_image_src($thumb_id, 'full', true);
$thumb_url = $thumb_url_array[0];
?>
<li><img src="<?php echo $thumb_url;?>" title="<?php echo get_the_title(); ?>" /></li>
<?php endforeach; wp_reset_postdata(); ?>
</ul>
</div>
<div id="main">
<div class="container">
<div class="row">
<?php if(have_posts()) : ?>
<?php while(have_posts()) : the_post(); ?>
<div class="col-sm-8">
<?php the_content(); ?>
</div>
<?php endwhile; ?>
<?php endif; ?>
<div class="col-sm-4">
<h3>Latest tweets</h3>
</div>
</div>
</div>
</div>
I hope that makes sense. Please let me know if my requirements are unclear.