WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Simple category question

[Resolved] Simple category question

  • Hi all,

    Here’s what I need to do:

    I have a category called ‘Free Market Reports’. It has several sub-categories.

    I then have posts assigned to those sub-categories (in some instances to several).

    I’d like to be able to list all of the sub-categories, then output an unordered list of all the posts assigned to each sub-category.

    Like this:

    <h2>Free Market Reports</h2>
    <h3>Sub-Category 1</h3>
    <ul>
    <li><a href="#">Post in sub-cat 1</a></li>
    <li><a href="#">Post in sub-cat 1</a></li>
    </ul>
    <h3>Sub-Category 2</h3>
    <ul>
    <li><a href="#">Post in sub-cat 2</a></li>
    <li><a href="#">Post in sub-cat 2</a></li>
    </ul>

    etc.

    Is this relatively simple?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Take a look at get_posts. That would give you the data for the subcategories at least. You probably would just have to run it for each subcategory

    Hope this helps,
    -drmike

    Thanks drmike 🙂

    I just discovered get_posts and I’m giving it a crack.

    I thought there must have been an easier way to do what I wanted using category tags.

    get_posts did the trick – thanks again!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] Simple category question’ is closed to new replies.