• OK I am trying to do something simple, but it appears it can’t be done. Any geniuses out there?

    I want a list of posts next to my actual posts in category.php. I’m not into making X number of category-1.php files so the list needs to come from the category it’s in. I tried to use have_posts() and the_post() but it only displays the set number of posts per page in the list, where as I’d rather it list 30 or so title links (the custom posts per page plugin isn’t really much help here).

    I tried get_posts() but that just grabs all posts regardless of category, or lets you specify a category to get posts from. Obviously not what I want for a generic category.php doc that serves all categories.

    HELP!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter dadako

    (@dadako)

    anyone want a stab at this??

    Thread Starter dadako

    (@dadako)

    OK I can see I’m not grabbing the attention of the wordpress gurus here ?? so I’ll explain a little more clearly:
    (although you may have to look at my site to see what I’m on about!)

    In the sidebars, you can list recent posts from categories like this:


    <...ul...>
    <?php
    $myposts = get_posts('numberposts=10&offset=0&category=5');
    foreach($myposts as $post) :
    ?>
    <...li...><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a><.../li...>
    <?php endforeach; ?>
    <.../ul...>

    Thats really useful for your main index.

    I have made a custom Categories page called “category.php” that is used automatically by wordpress when you click on any of the categories listed on my sidebar navigation ( [url]www.dadako.com[/url] )

    In this custom categories page, I have set a bit of code to show you what cat you are in:

    <?php $this_category = get_category($cat); ?><?php echo $this_category->cat_name; ?>

    Underneath that, I wanted to have a list of the last 30 or so posts in that category, although fictional, take a look at the following code to see how I “think” it should be done:


    <...ul...>
    <?php
    $myposts = get_posts('numberposts=30&offset=0&category=$this_category');
    foreach($myposts as $post) :
    ?>
    <...li...><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a><.../li...>
    <?php endforeach; ?>
    <.../ul...>

    Obviously it doesn’t work and I’m not quite sure of the correct syntax. Also at some point I will try to list thumbnails too, not just titles.

    any help would be greatly appreciated.

    juststoptime

    (@juststoptime)

    I think it’ll work if you take out the … in the li and ul tags.

    I’m trying to do the very same thing!

    I’ve got this code from “how to make your wordpress blog a magazine”, with this code you can get a specific number of posts… Not entirely sure how it should be used to the effect you (and me) are looking for though.

    <?php $posts = get_posts( "category=2&numberposts=30" ); ?> <?php if( $posts ) : ?> <?php foreach( $posts as $post ) : setup_postdata( $post ); ?> <a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a><?php endforeach; ?><?php endif; ?></div>

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘list of post titles in category.php’ is closed to new replies.