1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Wordpress: list most recent posts by specific category?

Discussion in 'WordPress' started by Pixelrage, Aug 31, 2007.

  1. #1
    Considering that this bit of code lists the 10 most recent posts:

    <?php get_archives('postbypost', 10); ?>
    Code (markup):
    ...how can I change it to display the 10 most recent posts from category ID 4, for example?
     
    Pixelrage, Aug 31, 2007 IP
  2. SkiRat44

    SkiRat44 Peon

    Messages:
    480
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #2
    <ul>
    <?php $recent = new WP_Query("cat=4&showposts=10"); while($recent->have_posts()) : $recent->the_post();?>
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endwhile; ?>
    </ul>
     
    SkiRat44, Aug 31, 2007 IP
  3. sat123

    sat123 Banned

    Messages:
    1,600
    Likes Received:
    45
    Best Answers:
    0
    Trophy Points:
    0
    #3
    This will show the title with permalink of last 10 posts (of cat 4) as a list but not the post contents..that's ideal for sidebar recent posts....for separate page u can show contents...by adding another line..or 2..
     
    sat123, Sep 1, 2007 IP
  4. Pixelrage

    Pixelrage Peon

    Messages:
    5,083
    Likes Received:
    128
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks very much - I appreciate it!

    If you know of any good sites that explain Wordpress coding, please post it here. I went through the official site, but it only talks about very basic things, and skips over other parts.

    edit: If you know of a way I can modify search results to display nothing but titles (instead of the entire post), that would be a big help, too :D
     
    Pixelrage, Sep 1, 2007 IP
  5. SkiRat44

    SkiRat44 Peon

    Messages:
    480
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #5
    My bad, this is what you want:

    <?php $recent = new WP_Query("cat=4&showposts=1"); while($recent->have_posts()) : $recent->the_post();?>
    <h1><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h1>
    <?php the_content(__('Read more'));?><?php endwhile; ?>
     
    SkiRat44, Sep 1, 2007 IP
  6. r3born

    r3born Active Member

    Messages:
    1,070
    Likes Received:
    51
    Best Answers:
    0
    Trophy Points:
    88
    #6
    There's also an old plugin called Customized Post Listings, try it out - might help.
     
    r3born, Sep 2, 2007 IP