• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

How do I show a Custom Taxonomy?

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › How do I show a Custom Taxonomy?

This topic is: not resolved

Tagged: Custom Post Type, metadata, taxonomy

  • This topic has 4 replies, 3 voices, and was last updated 12 years, 7 months ago by ischbins.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • September 12, 2013 at 8:50 am #62085
    jondonley
    Member

    Hello!

    I recently created a custom post-type called 'portfolio' following the tutorial that Brian Gardner made on his site: http://www.briangardner.com/portfolio-page/. I registered a new Custom Taxonomy called 'Location' and am looking to have the 'Location' present itself in the 'Portfolio' metadata.

    My current code in the functions.php file is as follows:

    function add_custom_taxonomies() {
    	// Add new "Locations" taxonomy to Posts
    	register_taxonomy('location', 'portfolio', array(
    		// Hierarchical taxonomy (like categories)
    		'hierarchical' => true,
    		// This array of options controls the labels displayed in the WordPress Admin UI
    		'labels' => array(
    			'name' => _x( 'Locations', 'taxonomy general name' ),
    			'singular_name' => _x( 'Location', 'taxonomy singular name' ),
    			'search_items' =>  __( 'Search Locations' ),
    			'all_items' => __( 'All Locations' ),
    			'parent_item' => __( 'Parent Location' ),
    			'parent_item_colon' => __( 'Parent Location:' ),
    			'edit_item' => __( 'Edit Location' ),
    			'update_item' => __( 'Update Location' ),
    			'add_new_item' => __( 'Add New Location' ),
    			'new_item_name' => __( 'New Location Name' ),
    			'menu_name' => __( 'Locations' ),
    		),
    		// Control the slugs used for this taxonomy
    		'rewrite' => array(
    			'slug' => 'locations', // This controls the base slug that will display before each term
    			'with_front' => false, // Don't display the category base before "/locations/"
    			'hierarchical' => true // This will allow URL's like "/locations/boston/cambridge/"
    		),
    	));
    }
    add_action( 'init', 'add_custom_taxonomies', 0 ); 
    
    /* ----------------------- PORTFOLIO CODE --------------------------- */
    /** Creates portfolio featured image for archive grid */
    add_image_size( 'portfolio', 330, 230, TRUE );
     
    /** Create portfolio custom post type */
    add_action( 'init', 'portfolio_post_type' );
    function portfolio_post_type() {
        register_post_type( 'portfolio',
            array(
                'labels' => array(
                    'name' => __( 'Portfolio' ),
                    'singular_name' => __( 'Portfolio' ),
                ),
                'exclude_from_search' => true,
                'has_archive' => true,
                'hierarchical' => true,
                'taxonomies'   => array( 'location' ),
                'menu_icon' => get_stylesheet_directory_uri() . '/images/icons/portfolio.png',
                'public' => true,
                'rewrite' => array( 'slug' => 'portfolio' ),
                'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'page-attributes', 'genesis-seo', 'genesis-cpt-archives-settings' ),
            )
        );
    }
     
    /** Change the number of portfolio items to be displayed (props Bill Erickson) */
    add_action( 'pre_get_posts', 'minimum_portfolio_items' );
    function minimum_portfolio_items( $query ) {
     
        if( $query->is_main_query() && !is_admin() && is_post_type_archive( 'portfolio' ) ) {
            $query->set( 'posts_per_page', '12' );
        }
     
    }

    Any suggestions as to how to make the Taxonomy stuff list where the post metadata would?

    Thanks in advance!

    September 12, 2013 at 2:46 pm #62145
    wpspeak
    Member

    Ok, I think I've done something like this and therefore I'd like to share it with you.

    1. Genesis already has a built in shortcode. There's a less-known shortcode to output any custom taxonomies, [post_terms].

    Ref: http://my.studiopress.com/docs/shortcode-reference/#post-terms-shortcode

    So you might use something like this [post_terms taxonomy="location"]

    2. You can put the shortcode in post info or post meta section (referred as Entry Meta in HTML5-enabled theme). Here are some links to customize it

    Entry Header

    Entry Footer

    3. Since we only want to output the custom tax in Portfolio CPT we can combine the code above with conditional tag and filter.

    Take a look at this link, see the second block of code

    4 Ways To Remove, Hide or Customize Specific Post Info Links in Genesis

    Hope that helps


    WP Speak | Help the Awesome #Genesiswp Community

    September 13, 2013 at 10:24 am #62285
    jondonley
    Member

    Hey wpspeak, thanks for responding!

    This is definitely very helpful information (and great links), but unfortunately it looks as though I may have somehow registered the Taxonomy incorrectly or be looking at the wrong label for calling upon the Taxonomy for the shortcode. I'm going to take another looksie and see what I've done incorrectly.

    (I've tried to add the taxonomy in every way possible presented by those links, but I always get a blank space where it should print, so obviously I've done something wrong!)

    September 13, 2013 at 12:36 pm #62321
    jondonley
    Member

    After taking a further look, it appears that the 'location' taxonomy isn't fully connecting (despite being able to add custom locations to Portfolio posts) or I am writing the PHP code for filtering in the taxonomy incorrectly.

    However, I think the latter might not be likely, as I've tried simply throwing the [post_terms] and [post_terms taxonomy="location"] shortcodes into the appropriate hook in Genesis Simple Hooks with nothing to show for it.

    Any ideas on what I might have done wrong?

    November 4, 2013 at 9:40 am #70844
    ischbins
    Member

    Hi all,
    just a comment from my side and a further question to this topic.


    @jondonley
    : I am using the Genesis "Simple Hooks" plugin and edited in the genesis_after_post_content Hook the following shortcode:

    [post_terms sep=", " before="Ausstattung: ", taxonomy="ausstattung"]

    So far it works fine. All my taxonomies from "ausstattung" are shown under my post.

    Now coming to my question: I don't know why, but the command before="Ausstattung: " doesn't work!?!?
    Furthermore it is shown the German word "Kategorie" before the list of taxanomies!
    I have no idea where this "Kategorie" comes from!
    Does anybody know how to get rid of this "Kategorie" and how to display before="Ausstattung: " ?

    Would be great, if anybody could give me a hint.
    Thanks in advance & best regards!

  • Author
    Posts
Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2026 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble