WordPress.org

Forums

Dropdown List of Custom Taxonomies/Categories (3 posts)

  1. ghostpool
    Member
    Posted 5 years ago #

    I'm using the following code in my backend (functions.php) to generate a list of my categories which can then by inserted into a drop down menu.

    /* Get Categories */
    $ghostpool_categories_obj = get_categories('hide_empty=0');
    $ghostpool_categories = array();
    $ghostpool_categories[] = '';
    foreach ($ghostpool_categories_obj as $ghostpool_cat) {
    	$ghostpool_categories[$ghostpool_cat->cat_ID] = $ghostpool_cat->cat_name;
    }
    array_unshift($ghostpool_categories, "Choose a category");

    I'm now trying to do the same for my custom post type categories but cannot figure out how to do it. Any help would be appreciated.

  2. Rev. Voodoo
    Member
    Posted 5 years ago #

    http://codex.wordpress.org/Function_Reference/get_terms

    not sure if this is correct as I only recently started messing with custom taxonomies myself, and just figured out how to display them in posts

    But would get_terms work rather than get_categories?

    I know get_the_term_list gets the terms for use in my posts using the custom taxonomy....

  3. ghostpool
    Member
    Posted 5 years ago #

    Hi Rev.,

    I've tried both, but I can't get either working in this context. I guess I'm missing something.

Topic Closed

This topic has been closed to new replies.

About this Topic