• Resolved GardenFork

    (@erochow)


    hi everyone,

    I’d like to have a list of the 5 most recent posts of a particular category on the main page of my WP site, https://gardenfork.tv

    I tried to use the Recent Posts Embed plug in, but no luck. I believe this can be done with template tags.

    But being a newbie to coding, i’m looking for help in formulating the code to drop into the Main Index Page .

    i’d like to list the 5 most recent posts for the Recipes category, and have each of those posts listed to be linked back to that specific post.

    thanks for your help, eric.

Viewing 2 replies - 1 through 2 (of 2 total)
  • MichaelH

    (@michaelh)

    <?php
        $args=array(
          'cat' => 6,
          'showposts'=>5,
          'caller_get_posts'=>1
        );
        $my_query = new WP_Query($args);
        if( $my_query->have_posts() ) {
          echo '5 recent 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
          endwhile;
        } //if ($my_query)
      wp_reset_query();  // Restore global post data stomped by the_post().
    ?>
    Thread Starter GardenFork

    (@erochow)

    wow. thanks for the super fast response. best, eric.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘List 5 most recent post of a category on main page’ is closed to new replies.