customization – Display Custom Taxonomy Name As A Shortcode


On my WordPress site I have created a custom taxonomy named “game” which lists different gaming titles. I want to be able to display the names of these titles on my posts using a shortcode.

Prior to creating a custom taxonomy, I was using WordPress’ default categories taxonomy, and had the following code (found on stack exchange) working well:

function shortcode_post_category () {
    $html = '';
    $categories = get_the_category();
    foreach( $categories as $category ){
        $html .= '<h2>' . strtoupper($category->name) . ' KEYBINDS</h2>';
    }
    return $html;
}
add_shortcode( 'category-keybinds', 'shortcode_post_category' );

From what I understand I need to change the get_the_categories to get_the_term(?) however with my very limited knowledge of php I cannot seem to get this to work on the new “game” taxonomy.