amritansh
9/26/2017 - 5:44 AM

Returns all the terms related to a posttype

Returns all the terms related to a posttype

/*
 * Returns all the terms related to a posttype
 */
get_all_the_terms($posttype, $taxonomy);

function get_all_the_terms($posttype, $taxonomy) {
    $result = array();
    $args = array(
        'hide_empty' => false,
    );
    $terms = get_terms($taxonomy, $args);
    if (is_array($terms) && count($terms) > 0) {
        foreach ($terms as $key1 => $value1) {
            $result[$value1->term_id] = $value1->name;
        }
    }
    return $result;
}