List post titles under each category

Community Forums Forums General Discussion List post titles under each category

This topic is: not resolved

This topic contains 3 replies, has 3 voices, and was last updated by  jennifergrayeb 1 year, 1 month ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #4097

    khcreativemedia
    Participant
    Post count: 5

    Hello all,

    I’m trying to create a page that shows the name of each category with a list of all post titles associated with that category. Each title should also be linked to the post. This will be for a blog with thousands of post. It needs to be similar to http://michaelhyatt.com/archives.

    I want to do it in a way that creates the least amount of page load time and calls to the database as well.

    Thanks for your help,

    Keith

    #4377

    Susan
    Moderator
    Post count: 9254

    Keith:

    This tutorial might help:

    http://www.wphub.com/tutorials/list-posts-from-one-category/


    Susan @ Graphically Designing I offer theme customizations I tweet!
    I’ve taken up the challenge! – help me answer some of the unanswered posts

    #4401

    khcreativemedia
    Participant
    Post count: 5

    Thank Susan. I just got it to work using the following code:

    <?php
    /**
    * Template Name: Minimum Archive
    */

    add_action( ‘genesis_after_loop’, ‘custom_archives’ );
    function custom_archives() {
    echo ‘<div>’;
    $cats = get_categories();
    foreach ($cats as $cat) {

    echo $category->name; //category name
    $cat_link = get_category_link($category->cat_ID);
    echo ‘<h3><a href=”‘.$cat_link.’”>’.$cat->name.’</a> </h3>’;

    query_posts(‘cat=’.$cat->term_id.’&showposts=500′);

    echo ‘<ul>’;

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

    <li><a href=”<?php the_permalink() ?>” rel=”bookmark” title=”<?php the_title(); ?>”><?php the_title(); ?> – <?php the_date(); ?></a></li>

    <?php endwhile;

    echo ‘</ul>’;
    }
    ?>
    </div>

    <?php
    }
    genesis();

    #58935

    jennifergrayeb
    Participant
    Post count: 20

    Did anyone find a solve for this? I see the code above but I’m not sure where I’m supposed to place it.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.