Forums

How do I make lists of posts based on category? (9 posts)

  1. brentontherefore
    Member
    Posted 1 year ago #

    I have a blog where I blog about three topics, and I assign each a category based on that.

    1. Personal
    2. Computers
    3. Theology

    My main blog just shows everything, however, I want a dedicated page with a list of all posts in each category. How can I do this?

  2. Micah Cooksey
    Moderator
    Posted 1 year ago #

    Here's what I'd recommend:

    1. Make a separate page for each category
    2. Duplicate your index.php file once for each category and name it something like index-personal.php
    3. Insert the following code at the beginning of each duplicate, replacing "personal with the category name":

      <?php
      /*
      Template Name: Personal
      */
      ?>

    4. Then, for each duplicate of your index php file, alter the loop to show results only from that category (I can describe this in greater detail if you need me to)
    5. Select the appropriate page template for each category page using the "quick edit" feature under the "pages" tab.

    Let me know if you need any further clarification.

  3. brentontherefore
    Member
    Posted 1 year ago #

    Hi, thanks so much you're awesome and that is helpful.

    I am really looking just to have a list of links to the different posts, not the actual posts themselves.

    In looking around I found wp_get_archives() which does nearly what I want to do:

    <?php wp_get_archives('type=postbypost&limit=25'); ?>

    This posts a list of the last 25 posts by title, and includes links to them. However, it gets ALL of them, but I want it to only get certain categories.

  4. wprock
    Member
    Posted 1 year ago #

    create three files category-personal.php, category-computers.php and category-theology.php.

    Now copy the all code from archive.php file and paste in three files.

    Hope that it will work.

  5. brentontherefore
    Member
    Posted 1 year ago #

    actually, the theme i'm using didn't have an archives.php, but i added it... now what? is it supposed to show up somewhere?

  6. wprock
    Member
    Posted 1 year ago #

    where are you showing the three category? Link would be like this http://www.x.com/personal

  7. brentontherefore
    Member
    Posted 1 year ago #

    that doesn't work. I have my test environment installed at /ann and i created a file category-sermons.php:

    http://brentonstrine.com/ann/sermons

  8. wprock
    Member
    Posted 1 year ago #

    upload .htaccess file.

  9. brentontherefore
    Member
    Posted 1 year ago #

    yeah, the .htaccess file is there.

    --EDIT--
    whoops, it was empty. put up a real one, but it's directing to the root domain now.

Topic Closed

This topic has been closed to new replies.

About this Topic