WordPress.org

Ready to get started?Download WordPress

Forums

How to Set Feed to Newest First & Specific Category (7 posts)

  1. andrew-s3
    Member
    Posted 10 months ago #

    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.

  2. andrew-s3
    Member
    Posted 10 months ago #

    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>
  3. andrew-s3
    Member
    Posted 10 months ago #

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

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

  4. esmi
    Forum Moderator
    Posted 10 months ago #

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

  5. andrew-s3
    Member
    Posted 10 months ago #

    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.

  6. esmi
    Forum Moderator
    Posted 10 months ago #

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

  7. andrew-s3
    Member
    Posted 10 months ago #

    Thanks for the link - I'll take a look!

Reply

You must log in to post.

About this Topic