WordPress.org

Ready to get started?Download WordPress

Forums

get taxonomy objects (3 posts)

  1. leggo-my-eggo
    Member
    Posted 2 years ago #

    I know I can get_object_taxonomies('post'), but is there a way to do the reverse: get_taxonomy_objects('category')?

    What I need is a list of all post_types (including posts, pages and custom post types) registered to a certain taxonomy.

  2. leggo-my-eggo
    Member
    Posted 2 years ago #

    I just found that I can do:

    $tax_objects = get_taxonomies('','objects');
    $tax_object_types = $tax_objects['category']->object_type;

    Is that the cleanest way?

  3. Grawl
    Member
    Posted 2 years ago #

    It's clean. I use the same constructions for taxonomy description:

    $taxonomy = 'team';
    $taxonomy_object = get_taxonomies('','objects');
    print $taxonomy_object[$taxonomy]->description

    and post type description:

    $postType = 'coworker';
    $postType_object = get_post_type_object($postType);
    print $postType_object->description;

Topic Closed

This topic has been closed to new replies.

About this Topic