Title: Incorrect content displayed
Last modified: August 19, 2016

---

# Incorrect content displayed

 *  Resolved [dashaluna](https://wordpress.org/support/users/dashaluna/)
 * (@dashaluna)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/incorrect-content-displayed/)
 * Hello everyone,
 * I have a page set up in WP with some content. In a template to display it I display
   the content of the page as following:
 *     ```
       <?php if (have_posts()) : while (have_posts()) : the_post();
         the_content();
         endwhile;
       endif; ?>
       ```
   
 * Which is correct.
 * Then in the template I choose all posts of my Design custom post type and loop
   through them. Each Design custom post has got native WP content, which I try 
   to display. However, instead of Design custom post type content the content of
   the page gets printed.
 * Here is the code where I loop through all Design custom post type posts and overwriting
   $post to a current Design post.
 *     ```
       <?php //get all Design custom post type posts
       $design_templates = get_posts("post_type=design");
   
       // Display all Design posts if any
       if(is_array($design_templates)) {
         //overwrite $post
         foreach($design_templates as $post) {
           $design_template_meta = get_post_meta($post->ID, 'vulcan_meta_screenshots', true );
       ?>
   
       <h3 id="<?php the_title(); ?>">
         <?php the_title(); ?>
       </h3>
   
       <?php the_content(); ?>
       <?php } // endforeach
       } //endif ?>
       ```
   
 * So in the loop the $post referes to the current Design post. It seems that $post-
   >ID and the_title() work correctly. However, the_content() still displays the
   page’s content, but not the current Design post. I don’t understand why.
 * Would really appreciate any help or explanation.
 * Many thanks,
    Dasha

Viewing 1 replies (of 1 total)

 *  Thread Starter [dashaluna](https://wordpress.org/support/users/dashaluna/)
 * (@dashaluna)
 * [15 years, 6 months ago](https://wordpress.org/support/topic/incorrect-content-displayed/#post-1742840)
 * Ok, I found it in here [http://codex.wordpress.org/Function_Reference/get_posts#Access_all_post_data](http://codex.wordpress.org/Function_Reference/get_posts#Access_all_post_data)
 * Seems that I’ve forgotten to set up post’s data with
 * `setup_postdata($post);`

Viewing 1 replies (of 1 total)

The topic ‘Incorrect content displayed’ is closed to new replies.

## Tags

 * [content](https://wordpress.org/support/topic-tag/content/)
 * [custom post type](https://wordpress.org/support/topic-tag/custom-post-type/)
 * [page](https://wordpress.org/support/topic-tag/page/)
 * [the_content](https://wordpress.org/support/topic-tag/the_content/)

 * 1 reply
 * 1 participant
 * Last reply from: [dashaluna](https://wordpress.org/support/users/dashaluna/)
 * Last activity: [15 years, 6 months ago](https://wordpress.org/support/topic/incorrect-content-displayed/#post-1742840)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
