• I’m trying to add a code in so that I can have the most recent published blog post (just 1) show under the appropriate section of my homepage. Can anyone help me? The code I’ve entered is not pulling in the post.

    What is currently there:
    <!–?php global $post; $myposts = get_posts(‘numberposts=1&category=1’); foreach($myposts as $post) : ?–>
    <!–?php the_title(); ?–>
    <!–?php the_content(); ?–>
    <!–?php endforeach; ?–>

    Thank you.

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    The PHP itself should work provided there is at least one post in the category with the ID of 1.

    As you posted the code though, it is formatted as HTML comments, not PHP code. You need to remove the comment delimiters to restore the PHP delimiters. Each line should look more like this: <?php the_title(); ?>

    The code inside the <?php ?> varies of course.

Viewing 1 replies (of 1 total)
  • The topic ‘Getting Most Recent Post To Show’ is closed to new replies.