• Resolved ohdiesel

    (@ohdiesel)


    Hello!

    Anyone have php code for the first 5 entries that I can list on my blog page?

    I want to list the latest 5 entries on my site, but as it is now, I am using only get_post which cannot do what I want it to.

    Any ideas?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Well get_posts should work but try:

    <?php
    $args=array(
      'post_type' => 'post',
      'post_status' => 'publish',
      'posts_per_page' => 5,
      'caller_get_posts'=> 1
    );
    $my_query = null;
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
      echo 'List of Posts';
      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(); //delete this if you only want post titles
      endwhile;
    }
    wp_reset_query();  // Restore global post data stomped by the_post().
    ?>
    Thread Starter ohdiesel

    (@ohdiesel)

    Muchos gracias

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Last 5 entries coding?’ is closed to new replies.