• Hi all,

    I’m using
    wp_get_archives('type=postbypost&limit=5')
    to show the latest 5 posts on my homepage:
    1. Post #1
    2. Post #2
    3. Post #3
    etc.

    But I’d like to also include the name of the category that each post belongs to. So that the list would look something like this:
    1. Post #1 [Category X]
    2. Post #2 [Category X]
    3. Post #3 [Category Y]
    etc.

    How would that be done?

    Thanks in advance.

Viewing 1 replies (of 1 total)
  • This, in a widget from Otto’s PHP Code Widget, or in a sidebar.php works:

    <?php
       $args=array(
       'showposts'=>5,
       'caller_get_posts'=>1
       );
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
    while ($my_query->have_posts()) : $my_query->the_post(); ?>
    <p><small><?php the_time('m.d.y') ?></small> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a> In Category:  <?php the_category(',','single'); ?></p>
    <?php
    endwhile;
    }
    ?>

Viewing 1 replies (of 1 total)
  • The topic ‘Getting Wp_get_archives to show category name’ is closed to new replies.