• I’m moving from Movabletype. I have a page that displays just the title, body and date of my most recent entry. I have then used this page as a php include on my main website so it updates every time I publish a new entry. How do I do this in WordPress?

Viewing 5 replies - 1 through 5 (of 5 total)
  • You can the Recent Posts widget and specifiy one post to be displayed if you are talking about your sidebar(s):

    Buth, this code will also display the most recent post:

    <?php
    $args=array(
      'post_type' => 'post',
      'post_status' => 'publish',
      'posts_per_page' => 1,
      'caller_get_posts'=> 1
    );
    $my_query = null;
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
      echo 'Most recent post';
      while ($my_query->have_posts()) : $my_query->the_post(); ?>
        <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
        <?php
        the_content('Read the rest of this entry &raquo;');
      endwhile;
    }
    wp_reset_query();  // Restore global post data stomped by the_post().
    ?>

    Will the above solution work if I want to pull the latest posts to a static home page I have set up?

    I want to display 3 posts from my index.php to my new static home page
    front_page.php.. how would I do this?

    Any help would be great.

    Thread Starter ae6dx

    (@ae6dx)

    MichaelH I tried this and when I view the page I get:

    Fatal error: Class ‘WP_Query’ not found in /home/craigbos/public_html/wordpress/wp-content/themes/the-lord-of-the-rings/recent-page.php on line 9

    Thread Starter ae6dx

    (@ae6dx)

    Where do I save the file with this code in it?

    You would create a Page Template and put the code in there. Remember after creating the Page Template to assign it to a page.

    Related:
    Why is there no Page Template option when writing or editing a Page?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Display most recent entry’ is closed to new replies.