Forums

[resolved] Multiple post listing of posts in a single category (9 posts)

  1. tdellaringa
    Member
    Posted 6 years ago #

    Hi there,

    I've looked through the codex but can't seem to figure this out. I have a page (I link to it using /category/cat-name) listing out posts from a single category - audio. This is the page:

    http://www.crossandthrone.com/category/audio-messages/

    I believe this uses the index.php page to display. The problem is, I have that set to show only 1 post, which is how I want it on the home page. But here, I'd like to show *all* posts in that category.

    What I really want is a link to the single.php page that shows all the posts in that one category. I looked in the codex under the category tag here:

    http://codex.wordpress.org/Template_Tags#Category_tags

    But couldn't quite figure out how to do what I want. Any help is greatly appreciated.

  2. tdellaringa
    Member
    Posted 6 years ago #

    Nobody has any ideas on this?

  3. moshu
    Member
    Posted 6 years ago #

    What I really want is a link to the single.php page that shows all the posts in that one category

    That's an oxymoron - I hope you realize it ;)
    The easiest way to have different number of posts on different views, use a plugin:
    http://mattread.com/archives/2005/03/custom-query-string-plugin/
    Another solution (involving a bit more work) - to have a category-X.php template (where X = cat ID#) and use a modified Loop with a query_posts.
    See also Category_Templates.

  4. tdellaringa
    Member
    Posted 6 years ago #

    Thanks Moshu - yeah you are right about that being an oxymoron! The plugin looks promising, but maybe a category.php page will suffice for me.

    Edit: Ok, I think I get the gist - but I still only get one post and maybe that is what you meant by suggesting the plugin. I am doing this:

    --------
    <?php get_header(); ?>

    <!-- content ................................. -->
    <div id="content" style="width: 725px;">

    Audio listing

    <?php if (have_posts()) : ?>

    <?php while (have_posts()) : the_post(); ?>

    <div class="entry">
    <p class="date"><?php the_time('F jS, Y') ?>
    <h2 id="<?php the_ID(); ?>">" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></h2>

    <?php the_excerpt(); ?>

    </div>

    <?php endwhile; ?>

    <?php else : ?>

    <h2>Not Found</h2>
    Sorry, but you are looking for something that isn't here.
    <?php include (TEMPLATEPATH . "/searchform.php"); ?>

    <?php endif; ?>

    </div> <!-- /content -->

    <?php get_footer(); ?>
    ----------

    I get the category page which is great - is there any way outside the plugin to have this list *ALL* the posts in this category? Then I've got what I need!

  5. moshu
    Member
    Posted 6 years ago #

    Click the query_posts link I gave above.

  6. tdellaringa
    Member
    Posted 6 years ago #

    Ahh thanks Moshu - that is exactly what I needed! For those who want to know what I did - made category-9.php (9 is my audio cat) and have this as code:

    <?php get_header(); ?>

    <!-- content ................................. -->
    <div id="content" style="width: 725px;">

    <h2>Audio Messages</h2>

    <?php if (have_posts()) : ?>
    <?php query_posts('showposts=10&cat=9'); ?>
    <?php while (have_posts()) : the_post(); ?>

    <div class="entry" style="margin:0;padding:0;">
    <h3 id="<?php the_ID(); ?>">" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?> (<?php the_time('F jS, Y') ?>)</h3>

    <?php the_excerpt(); ?>

    </div>

    <?php endwhile; ?>

    <?php else : ?>

    <h2>Not Found</h2>
    Sorry, but you are looking for something that isn't here.
    <?php include (TEMPLATEPATH . "/searchform.php"); ?>

    <?php endif; ?>

    </div> <!-- /content -->

    <?php get_footer(); ?>

    ---------

    Gives me 10 posts in that category (I think the cat=9 is redundant now, since I specify that in the php name of the file.

  7. syncbox
    Member
    Posted 6 years ago #

    uh, the cat=9 refers to the category id, not the number of posts, just fyi.

  8. Dgold
    Member
    Posted 6 years ago #

    "Gives me 10 posts in that category"

    I thought you said you wanted to display *all* the posts in the category?

  9. donmagnus
    Member
    Posted 6 years ago #

    Instead of making a new file for each category you could enter this into the archive template:

    <?php query_posts("showposts=10&cat=$_GET[cat]"); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.