WordPress.org

Ready to get started?Download WordPress

Forums

Show category post titles in sidebar (3 posts)

  1. killjoy333
    Member
    Posted 7 years ago #

    Ok I'm fairly new to modifying Word Press so bear with me. What I would like to do is modify the sidebar so that it will only show POSTS from the CURRENT CATEGORY only.

    I currently have 2 categories and would like it so that when you are viewing one of the categories it will show all the post titles from the current category you are viewing only (in the sidebar).

    Please let me know if you can hlep. Currently I have only got it to show all the post titles from category 3 only by using the code below:

    <?php $temp_query = $wp_query; ?>
    <?php query_posts('cat=3&showposts=50'); ?>
    <?php while (have_posts()) : the_post(); ?>
    <p>"><?php the_title(); ?></p>
    <?php endwhile; ?>
    <?php $wp_query = $temp_query; ?>

    Website is: http://www.happyskateboarding.com/sklog/?cat=3

    Thanks in advance,

  2. MarkMichon
    Member
    Posted 7 years ago #

    I haven't tested this, but try something like this:
    <?php if ( is_category('3') ) { ?>

    All your Cat 3 stuff, like you have it

    <?php } else if ( is_category('2') ) { ?>

    Some stuff as cat 3, but with 2s.

    <?php } ?>

    I'm not great at the syntax, but that should do it.

  3. killjoy333
    Member
    Posted 7 years ago #

    Oh i see... yeah just put the conditional statement in so that it can decide what to show. Good call... I'll try and let you know.

    THanks!

Topic Closed

This topic has been closed to new replies.

About this Topic