Support » Fixing WordPress » How To show the post titles of a currently opened category in my sidebar

  • Hi,

    I’m just creating a page for a client and I need some help with categories and post-titles.

    I created some categories which are displayed as <?php wp_list_categories('title_li=&include=4,9,17,19,20'); ?> in my sidebar.
    When i click a category i see the posts that are in the “current” category. Everything works fine.
    But its a long way to scroll to see all of them.

    Is there any possibility, after I click on the category I want to browse, to display the post titles that are in that category like:

    category a
    category b (clicked)
    post title 1
    post title 2
    post title 3
    category c
    category d
    etc…

    but when I i.e. click on category a i want to display only post titles that are in category a in my sidebar, like:

    category a (clicked)
    post title 1
    post title 2
    post title 3
    category b
    category c
    category d
    etc, etc..

    Please help me because I really don’t know how to do this.

Viewing 2 replies - 1 through 2 (of 2 total)
  • So you want a sort of expandable post list. I think you could get post lists for all your categories in the sidebar first, then hide them using CSS (display: none;). And then use a simple JavaScript toggle which happens when you click a category link, to “unhide” them.

    Makes sense? But don’t ask me to actually write it all since I haven’t done anything like this before 🙂

    Edit: there are lots of toggle code examples online, like this:

    http://circlecube.com/2007/11/javascript-code-to-show-a-hidden-element/

    Thread Starter tjdesign

    (@tjdesign)

    hmm i thought about some php something like

    <?php wp_list_categories('title_li=&include=3,5,6,8,7'); ?>
    <?php if(have_posts()) : while(have_posts()) : the_post(); ?>
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endwhile; ?>
    <?php else : ?>
    <?php endif; ?>

    This works but the titles are displayed like:
    category a (clicked)
    category b
    category c
    post title a (category a)
    post title b (category a)
    post title c (category a)

    thats not really good looking and it makes no sense

    and when i click on a post the category post titles disappear the only one thats staying is the one i’m on….

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How To show the post titles of a currently opened category in my sidebar’ is closed to new replies.