get_posts() pulling incorrect data
I am trying to put my latest post on my static front page using the following php code:
<?php global $post; $myposts = get_posts('numberposts=1'); foreach($myposts as $post) : ?> <?php the_title(); ?> <?php the_content(); ?> <?php endforeach; ?>
For some reason the data that is displayed comes from two different posts. the_title() is returning the correct post title (the most recent), however the_content() is returning the text from my first post, not the most recent. As they both reside in the same loop I don’t really understand what’s going wrong to pull two seperate posts at the same time.
Has anyone experienced this themselves? Would anyone know what I can do to fix this?
So far I have tried different php codes, deleting most of the plugins, emptying both the wp_postmeta and wp_posts database tables and re-entering the posts from scratch. I have also reuploaded the wp-includes folder to my server. Nothing so far seems to work..
- The topic ‘get_posts() pulling incorrect data’ is closed to new replies.