• I’m trying to use WordPress as a CMS. I’m using a home.php to have a different page style for the home page. Now I have a News category and I want the most recent post of that category to be displayed on the home page. Here is what I tried:
    <?php

    $posts = get_posts(‘numberposts=1&offset=0&category=2’);
    foreach($posts as $post)
    {
    the_excerpt();
    }

    ?>

    Now this kinda sorta works, but it gets me the excerpt of the latest post or the first 120 words. I tried using the_content() instead of the_excerpt() but it doesn’t give me anything. Is there a better way of getting the latest post for a certain category?

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Get Latest Post In Category’ is closed to new replies.