[resolved] List Category Post Titles (3 posts)

  1. bokinuk
    Posted 10 years ago #

    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?

  2. bokinuk
    Posted 10 years ago #

    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!

  3. Ulrika
    Posted 10 years ago #

    Thanks bokinuk
    Your a darling;-)

Topic Closed

This topic has been closed to new replies.

About this Topic