• Hi there,

    my website: http://jeremyvandermeij.com

    On my main page instead of showing all my posts oragnized by date, i would like to show my posts according to category with category titles and each category of posts in a separate row.

    Each category could be displayed the same to how it looks when you go to the archive page of each category.

    Can anyone help?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Print categories and posts

    <?php
    $categories=get_categories('orderby=name&amp;order=ASC');
      foreach($categories as $category) {
          $posts=get_posts('showposts=-1&amp;cat='. $category->term_id);
          if ($posts) {
            echo '<p>Category: <a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> </p> ';
            foreach($posts as $post) {
              setup_postdata($post); ?>
              <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
              <?php
            } // foreach($posts
          } // if ($posts
        } // foreach($categories
    ?>

    Thread Starter JeremyV

    (@jeremyv)

    Hey!

    Thanks! I’m not sure where I am supposed to put this code. I’m a newbie 😀

    Thanks!

    Thread Starter JeremyV

    (@jeremyv)

    I just tried that code somewhere else and it didn’t seem to do what I wanted. I’m looking to list my posts visually the same way they are on my existing homepage except instead of ordered by date they would be ordered into categories with titles.

    That code could be used in place of your existing Loop in your theme’s index.php but you will want to make sure any div’s and the like are honored.

    Related:

    Stepping Into Templates
    Template Hierarchy

    Thread Starter JeremyV

    (@jeremyv)

    well. I still can’t seem to get it. I tried and it just lists them in words and I need them listed in thumbnails.

    Thanks nonetheless!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Show Posts w/ Category Title on Main Page’ is closed to new replies.