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
The topic ‘Incorrect content displayed’ is closed to new replies.