• Resolved Storyman

    (@storyman)


    The goal is to have only the article titles of a particular category display in a list on the sidebar.

    I’ve been able to accomplish this by creating a sub-category with the same name as the title for every post. That creates a lot of sub-categories.

    It seems that a cleaner, simpler approach would be to display only the post titles for a specific category. After digging through previous post and the WordPress documents I’ve been unable to figure it out. I’m sure that I’ve overlooked something simple.

    How to display only the post titles for a particular category? –and not the category title itself!

Viewing 1 replies (of 1 total)
  • Try this:

    <?php if ( is_category('3') ) : ?>
    <li>
    <h2>News</h2>
    <ul>
    <?php
    $posts = get_posts('numberposts=10&category=3&orderby=post_title&order=ASC');
    foreach($posts as $post) :
    ?>
    <li>
    <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
    </li>
    <?php endforeach; ?>
    </ul>
    </li>
    <?php endif ; ?>

    Rich

Viewing 1 replies (of 1 total)
  • The topic ‘Display post titles from a single category’ is closed to new replies.