Support » Fixing WordPress » List Category Post Titles

  • Resolved bokinuk


    Hi – I’m trying to list the category post titles in the sidebar of the category pages. There are a number of solutions in this forum, but none of them work when a post is in more than one category.

    I’m not a coder, and this might be obvious to those who are, but help out here please.

    (a) If I put the following in my sidebar, it generates a category number (a single number) which I see displayed in the sidebar when browsing through my blogs category pages –

    <?php echo($cat); ?>

    (b) The following displays a list the post titles from a particular category when I manually enter the category number in place of XX –

    <?php query_posts('cat=XX&showposts=-1'); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div class="post">
    <h3 class="storytitle" id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></h3>
    <?php endwhile; else: ?>
    <?php _e('Sorry, no posts matched your criteria.'); ?>

    <?php endif; ?>

    How can the results of (a) be substituted into (b) in place of the XX on an automatic basis?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hail hail to the newly crowned king of hack – ME. Put that in your pipes and smoke it gurus.

    With heaps of credit to Brian Groce and his, WP Category Posts Plugin. I made the smallest of tweaks (if you can call it that) and this issue is now resolved on my blog.

    As I said earlier there are a number of solutions to list posts and post titles of a category. They all fell over when posts are in more that one category. As an aside, I also wanted the list of posts to be in the blogs column – sidebar.php.

    Enter Mr Groce. I installed his plugin, added the code in the sidebar – and here’s my contribution – instead of entering a category number, I used $cat. And that does the trick for me. It’s dynamic, automatic and does precisely what I want.

    Use this line with the ‘WP Category Posts Plugin’.
    <?php wp_cat_posts($cat); ?>

    Thank #!*! for that, now I can get on with my life!

    Thanks bokinuk
    Your a darling;-)

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘List Category Post Titles’ is closed to new replies.