• After searching high and low I’m going to break down and ask for some help please.

    When I go to a Category page I want to list all the post titles from only that Category on the sidebar. I see solutions where a category number or numbers are included in the argument, but that’s too static for my purposes.

    I discovered this code in my searches and it does exactly what I need … except when a post is in more than one category. A number of things could happen then: i.e. all the blogs post titles are displayed .. etc etc

    Could someone please tell if an argument can be included in this so only the post titles of the category page currently being displayed are shown on the sidebar? Many thx.

    <?php
    $cat = get_the_category();
    $cat = $cat[0];
    $posts = get_posts("category=" . $cat->cat_ID . "&numberposts=5");
    if( $posts ) :
    ?>
    <div class="recent-posts">
    <ul>
    <?php foreach( $posts as $post ) : setup_postdata( $post ); ?>
    <li><a href="<?php the_permalink() ?>" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></li>
    <?php endforeach; ?>
    </ul>
    </div>
    <?php endif; ?>

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘List Category Post Titles’ is closed to new replies.