WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Simple category question (4 posts)

  1. waydomatic
    Member
    Posted 7 years ago #

    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?

  2. drmike
    Member
    Posted 7 years ago #

    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

  3. waydomatic
    Member
    Posted 7 years ago #

    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.

  4. waydomatic
    Member
    Posted 7 years ago #

    get_posts did the trick - thanks again!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags