WordPress.org

Support

Support » How-To and Troubleshooting » How to Set Feed to Newest First & Specific Category

How to Set Feed to Newest First & Specific Category

  • I’m attempting to modify the current code to display The most recent post, followed by the next 4 recent posts from a specific category – in this case, category 4.

    here’s my code:

    <ul class="recent-posts">
    <!-- LOOP START -->
    <?php $the_query = new WP_Query( 'showposts=5' ); ?>
        <?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
        <!-- THIS DISPLAYS THE POST THUMBNAIL, The array allows the image to has a custom size but is always kept proportional -->
    
    <li><?php the_post_thumbnail( array(100,100) );?></li>
          <!-- THIS DISPLAYS THE POST TITLE AS A LINK TO THE MAIN POST -->
    
    <li><h3><a>"><?php the_title(); ?></a></h3></li>
          <!-- THIS DISPLAYS THE DATE/AUTHOR META DATA -->
    
    <li><span class="featured-data">Posted by <?php the_author_posts_link(); ?> in <?php the_category(', '); ?> | <?php the_time('F d, Y'); ?></span></li>
          <!-- THIS DISPLAYS THE EXCERPT OF THE POST -->
    
    <li><?php the_excerpt(); ?></li>
          <!-- READ MORE LINK -->
    
    <li><a>" class="read-more">Read More...</a></li>
          <hr />
        <?php endwhile;?>
    <!-- LOOP FINISH -->

    Thanks for your help in advance.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Sorry for the duplicate code – it posted wrong the first time

    <ul class="recent-posts">
    <!-- LOOP START -->
    <?php $the_query = new WP_Query( 'showposts=5' ); ?>
        <?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
        <!-- THIS DISPLAYS THE POST THUMBNAIL, The array allows the image to has a custom size but is always kept proportional -->
          <li><?php the_post_thumbnail( array(100,100) );?></li>
          <!-- THIS DISPLAYS THE POST TITLE AS A LINK TO THE MAIN POST -->
          <li><h3><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h3></li>
          <!-- THIS DISPLAYS THE DATE/AUTHOR META DATA -->
          <li><span class="featured-data">Posted by <?php the_author_posts_link(); ?> in <?php the_category(', '); ?> | <?php the_time('F d, Y'); ?></span></li>
          <!-- THIS DISPLAYS THE EXCERPT OF THE POST -->
          <li><?php the_excerpt(); ?></li>
          <!-- READ MORE LINK -->
          <li><a href="<?php the_permalink() ?>" class="read-more">Read More...</a></li>
          <hr />
        <?php endwhile;?>
    <!-- LOOP FINISH -->
    </ul>

    I figured it out – changed my query to the following:

    <?php $the_query = new WP_Query( 'cat=4&order=ASC&showposts=5' ); ?>

    esmi

    @esmi

    Forum Moderator

    Try <?php $the_query = new WP_Query( 'cat=4&order=ASC&posts_per_page=5' ); ?>. showposts is deprecated.

    Thanks for the update ESMI – I’ll make that change now.

    Is there any way that I can incorporate the “Mullet Loop” i.e. display the most recent post in full; then the next 4 recent posts as excerpts?

    I’ve been trying to find sample code, but nothing I’ve found thus far works properly.

    esmi

    @esmi

    Forum Moderator

    Have a look through the solutions posted in http://wordpress.org/search/display+first+post+in+full?forums=1

    Thanks for the link – I’ll take a look!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to Set Feed to Newest First & Specific Category’ is closed to new replies.
Skip to toolbar