• It’s probably been asked before – but I cant seem to find it.

    Does anyone know of a way to show the most 10 recent posts from a category inside a page?

    Any help is greatly appreciated.

Viewing 3 replies - 1 through 3 (of 3 total)
  • This article explains how to list recent posts from one category on the sidebar.

    http://www.kimwoodbridge.com/wordpress-how-to-list-recent-posts-from-one-category/

    If you want to put this code on a page you would want to make a custom page template and the code to it.

    http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates

    <?php
    //display 10 posts for category id 47
        $args=array(
          'cat' => 47,
          'post_type' => 'post',
          'post_status' => 'publish',
          'posts_per_page' => 10,
          '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
          endwhile;
        }
    wp_reset_query();  // Restore global post data stomped by the_post().
    ?>

    Related:
    Pages
    Stepping Into Template Tags
    Stepping Into Templates
    Template Hierarchy

    Hello, I’ve been struggling with this same issue for about an hour or more now…I’ve tried importing via SimplePie, random WP functions, and then this method and it seems something is wrong with my use of every one of them.

    This one gets the closest, but it messes up my main loop on the home page.

    I’ve got a home page displaying by default, with a loop to grab its content. Then on that same page’s template there’s another loop using the code from the article above to pull the title from the most recent news post on a sort of page-sidebar. It seems the two loops are fighting, and if I take out the ‘recent news’ loop, the ‘home page’ one works, but if I add in the ‘recent news’ loop, it replaces the ‘home page’ content with the ‘recent news’ post content.

    It’s pretty frustrating, and my PHP knowledge is basically nil. Any ideas?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Show 10 recent posts from only 1 category’ is closed to new replies.