Support » Fixing WordPress » How can I show the last 10 post titles for a certa

  • Dave

    (@dave)


    I would like to display the 5 or 10 most recent post titles for a given category in the rightside menu.
    How can I do this?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Dave

    (@dave)

    That worked perfectly. Thanks so much.

    davidchait

    (@davidchait)

    Yeah, I had already done a similar mod about a week back. Except I added a ‘postbycat’ search type for a bit more flexibility in my case handling. If you go to http://www.chait.net, and choose one of the category tabs along the top, the Last 5 Posts block on the right changes to Last 5 in [cat] instead. I like it — makes the site more ‘context sensitive’. 😉
    =d

    Jaykul

    (@jaykul)

    huh?
    Changing your call from:
    <?php get_archives('postbypost', '5', 'html', '

  • ', '
  • ', false, '7'); ?>
    To:
    <?php get_archives('postbypost', '5', 'html', '

  • ', '
  • ', false, $cat); ?>
    Would result in calling whatever the active ‘cat’egory is…. You could even specify a default, although I haven’t tested the WAY that I wrote it here (I probably have typos galore):
    <?php get_archives('postbypost', '5', 'html', '

  • ', '
  • ', false, ($cat=='')?'7':$cat); ?>

davidchait

(@davidchait)

Yeah, something like that would work. Though you need to watch for $cat==’all’ as a case too. There’s not a huge difference between approaches here… they’re pretty darn close.
I guess the other reason to not have a new archive retrieval ‘type’ like I did it is that you could use the category filter for things other than postbypost… Hmmm… now that I think of it, that could be useful for some people. That is, rather than necessarily the last 5 posts in a category, a given month’s postings in that category.. Hey, that’s kinda cool. Off to code! 😉
=d

davidchait

(@davidchait)

btw, that was REALLY easy… I just set up a new variable $post_cat_select_rule at the top of the fn based on if(empty($cat)), and added it in place of the post_category check in each of the SQL queries. if people are interested, I can post the useful snippets here. should have it up on chait.net later tonight (though you won’t really see a change in functionality at the moment!).
=d

debwire

(@debwire)

How do we do the same for the most recent comments? That’s what I am really looking for…

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How can I show the last 10 post titles for a certa’ is closed to new replies.