• 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: https://www.happyskateboarding.com/sklog/?cat=3

    Thanks in advance,

Viewing 2 replies - 1 through 2 (of 2 total)
  • 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.

    Thread Starter killjoy333

    (@killjoy333)

    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!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Show category post titles in sidebar’ is closed to new replies.