WordPress.org

Ready to get started?Download WordPress

Forums

Find out the CategoryID of a selected item in a Dropdown List (2 posts)

  1. dabhandconz
    Member
    Posted 1 year ago #

    I want to make a conditional dropdown list that displays the Child Categories of a selected Parent in a previous dropdown list.

    So basically if a user chooses City from a dropdown list, I need a way of grabbing that Category ID and telling a second dropdown list to show the Towns within that City.

    So to the user it looks like this:
    [List of Cities] *choose* [List of Towns within that City]

    in the backend it's this:
    [List of CategoryIDs] *choose* [Children of selected CategoryID]

    It would then go further.
    Using the ID of the selected Child Category (in the second dropdown), I would then want to display a list of Posts within that Category ID.

    So to the user:
    [List of Cities] *choose* [List of Towns within that City] *choose* [List of Stores]

    In the backend:
    [List of CategoryIDs] *choose* [Children of selected CategoryID] *choose* [List of Posts within ChildCategoryID]

    So as far as I can tell I just need to be able to grab the CategoryID of a selected item, yes?

    Any help would be appreciated.

  2. Pioneer Valley Web Design
    Member
    Posted 1 year ago #

    wp_get_post_categories should work...

Topic Closed

This topic has been closed to new replies.

About this Topic