• I want to list the titles of posts from a certain category in the sidebar. I read the codex and thought doing some thing like this might work:

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post();
    if ( in_category('3') ) { ?>
    <h3>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
    <?php the_title(); ?></h3>
    <?php }
    endwhile;
    else: ?>
    <p><?php _e('Sorry, no posts matched your criteria...yet'); ?></p>
    <?php endif; ?>

    But I’m coming up empty. I got the cat id from the categories page under posts. have also tried getting the by the category name, but that doesn’t seem to be working either.

    Thanks,
    sparkii

Viewing 2 replies - 1 through 2 (of 2 total)
  • You might want to read up on using Multiple Loops.

    Thread Starter mozity

    (@mozity)

    Wow, thanks so much for pointing me in right direction!! Worked perfectly.

    For anyone else who might want something similar here is my code.

    <h2>Noteworthy</h2>
    <?php // Get  10 posts in the noteworthy category.
         query_posts('category_name=noteworthy&posts_per_page=10'); ?>
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post();
    //make sure its in the cat then display.
     if ( in_category('noteworthy') ) { ?>
      <h4><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h4>
     <?php } endwhile;  else: ?>
       <p><?php _e('Sorry, no posts matched your criteria...yet'); ?></p>
     <?php endif; ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Specific category post titles in sidebar’ is closed to new replies.