title: Wordpress - Multiple loops on a page
body: <p>I have got multiple loops on a page. First loop gets the posts from <code>update</code> post type, second loop gets a page link, third one gets <code>post</code> post type, again fourth one gets a specific page link and then there is the last loop that fetches the current page data. i.e. I have got something like the following:</p>
  
  <p>Fetch the updates</p>
  
  <pre><code>&lt;?php $updates = get_posts(array('post_type' =&gt; 'update', 'post_per_page' =&gt; 4)); ?&gt;
  &lt;?php foreach ($updates as $update): ?&gt;
      &lt;?php setup_postdata($update); ?&gt;
      &lt;li&gt;
          &lt;span&gt;&lt;?php the_time(get_option('date_format')); ?&gt;&lt;/span&gt;
          &lt;h4&gt;&lt;a href="&lt;?php echo $update-&gt;guid; ?&gt;"&gt;&lt;?php echo get_post_meta($update-&gt;ID, 'msp_onhome_title', true); ?&gt;&lt;/a&gt;&lt;/h4&gt;
      &lt;/li&gt;
  &lt;?php endforeach ?&gt;
  </code></pre>
  
  <p>Fetch the <code>news</code> page link:</p>
  
  <pre><code>&lt;?php
      $the_slug = 'news';
      $args=array(
        'name' =&gt; $the_slug,
        'post_type' =&gt; 'page',
        'post_status' =&gt; 'publish',
        'numberposts' =&gt; 1
      );
      $blog_page = get_posts($args);
  
      if( $blog_page ) : 
  ?&gt;
      &lt;span class="stylish-extend"&gt;
          &lt;a href="&lt;?php echo $blog_page[0]-&gt;guid; ?&gt;"&gt;More News &amp;rarr;&lt;/a&gt;&lt;/span&gt;                                    
  &lt;?php endif; ?&gt;
  </code></pre>
  
  <p>Fetch posts:</p>
  
  <pre><code>&lt;?php $color_classes = array('dark-blue', 'dark-red', 'black', 'maroone', 'light-blue'); ?&gt;
  
  &lt;?php $posts = get_posts(array('post_type' =&gt; 'post', 'post_per_page' =&gt; 5)); ?&gt;
  &lt;?php foreach ($posts as $post): ?&gt;
      &lt;?php setup_postdata($post); ?&gt;
      &lt;li&gt;
          &lt;article class="blog-post"&gt;
              &lt;header&gt;
                  &lt;p class="post-title dark-blue"&gt;
                      &lt;a href="&lt;?php echo $post-&gt;guid; ?&gt;"&gt;&lt;?php the_title(); ?&gt;&lt;/a&gt;
                      &lt;span&gt;Posted in &lt;i&gt;&lt;?php the_category(', '); ?&gt;&lt;/i&gt; by &lt;i&gt;&lt;?php the_author(); ?&gt;&lt;/i&gt;&lt;/span&gt;
                  &lt;/p&gt;
              &lt;/header&gt;
          &lt;/article&gt;
      &lt;/li&gt;
      &lt;!-- &lt;span&gt;&lt;?php the_time(get_option('date_format')); ?&gt;&lt;/span&gt; --&gt;
  &lt;?php endforeach ?&gt;
  </code></pre>
  
  <p>Fetch Page link</p>
  
  <pre><code>&lt;?php
      $the_slug = 'blog';
      $args=array(
        'name' =&gt; $the_slug,
        'post_type' =&gt; 'page',
        'post_status' =&gt; 'publish',
        'numberposts' =&gt; 1
      );
      $blog_page = get_posts($args);
  
      if( $blog_page ) : 
  ?&gt;
          &lt;a href="&lt;?php echo $blog_page[0]-&gt;guid; ?&gt;"&gt;Head to blog &amp;raquo;&lt;/a&gt;
  
  &lt;?php endif; ?&gt;
  </code></pre>
  
  <p>Fetch the actual page content (current page)</p>
  
  <pre><code>&lt;!-- Problem here --&gt;
  &lt;section id="meet" class="light"&gt;
      &lt;?php if (have_posts()): while( have_posts() ) : the_post();  ?&gt;
          &lt;?php the_content(); ?&gt;
      &lt;?php endwhile; endif; ?&gt;
  &lt;/section&gt;
  </code></pre>
  
  <p>The problem lies here i.e. it doesn't show the actual page content. Strangely, when I take this loop above all the loops at the top most position, it shows the page data correctly. I have tried <code>wp_reset_query()</code> and <code>wp_reset_post_data()</code> (or was it <code>wp_reset_postdata()</code>?) after each of the loop but it didn't work. Another thing I tried is, saved the reference of the <code>$wp_query</code> in a variable, performed the loops and then restored the <code>$wp_query</code> i.e. like the following:</p>
  
  <pre><code>global $wp_query;
  $temp_wpquery = $wp_query;
  
  // perform all the loops and stuff
  
  global $wp_query;
  $wp_query = $temp_wpquery;
  
  // perform the stuff
  </code></pre>
  
  <p>Still the results were same. Can any body please tell me what am I doing wrong here? Why doesn't it show the current page data in the last loop?</p>