• 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 to display custom taxonomy terms

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 › General Discussion › How to display custom taxonomy terms

This topic is: not resolved

Tagged: custom taxonomies

  • This topic has 2 replies, 2 voices, and was last updated 11 years, 4 months ago by Sridhar Katakam.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • January 2, 2014 at 3:01 pm #82750
    shelley423
    Member

    I have added a custom taxonomy called "stores". Each post will have a category, store, and tags. This is NOT on a custom post type. My problem is I can't figure out to make the link to the terms under the store to display in the theme.

    So for example, a post about a toy sale on Amazon might be in the category "Online Deals", listed under the store "Amazon" and tagged "toys".

    On the bottom of the post, in the post meta, I want it to display categories and store and I can't get it to display the store. This is what I entered in functions.php and only categories show up.

    //* Customize the post meta function
    add_filter( 'genesis_post_meta', 'sp_post_meta_filter' );
    function sp_post_meta_filter($post_meta) {
    if ( !is_page() ) {
    	$post_meta = 
            the_terms( $post->ID, 'category', 'Categories: ', ' , ' );
            the_terms( $post->ID, 'stores', 'Store: ', ', ', ' ' ); 
        return $post_meta;
    }}

    This is what I did to add the taxonomy "stores":

    // hook into the init action and call create_taxonomies when it fires
    add_action( 'init', 'sh_create_taxonomies', 0 ); 
    
    // create new taxonomies for the post type "post"
    function sh_create_taxonomies() { 
        
        // Add new taxonomy, make it hierarchical (like categories)
        $labels = array(
            'name'                          => _x( 'Stores', 'stores' ),
            'singular_name'                 => _x( 'Store', 'stores' ),
            'search_items'                  => _x( 'Search Stores', 'stores' ),
            'popular_items'                 => _x( 'Popular Stores', 'stores' ),
            'all_items'                     => _x( 'All Stores', 'stores' ),
            'parent_item'                   => _x( 'Parent Store', 'stores' ),
            'parent_item_colon'             => _x( 'Parent Store:', 'stores' ),
            'edit_item'                     => _x( 'Edit Store', 'stores' ),
            'update_item'                   => _x( 'Update Store', 'stores' ),
            'add_new_item'                  => _x( 'Add New Store', 'stores' ),
            'new_item_name'                 => _x( 'New Store', 'stores' ),
            'separate_items_with_commas'    => _x( 'Separate stores with commas', 'stores' ),
            'add_or_remove_items'           => _x( 'Add or remove stores', 'stores' ),
            'choose_from_most_used'         => _x( 'Choose from the most used stores', 'stores' ),
            'menu_name'                     => _x( 'Stores', 'stores' ),
        ); 		
        
        $args = array(
    	'labels'            => $labels,
            'public'            => true,
            'show_in_nav_menus' => true,
            'show_ui'           => true,
            'show_tagcloud'     => true,
            'show_admin_column' => true,
            'hierarchical'      => true,
            'query_var'         => true,
    	'rewrite'           => 
                array(
                    'slug' => 'stores', 
                    'with_front' => false, // Don't display the category base before "/Stores/"
                    'hierarchical' => true ),
        );
            
        register_taxonomy( 'store', array('post'), $args );            
    }

    It also seems that the store doesn't show up under the admin column, which may or may not be related?
    admin panel

    I am using the Adorable theme.

    I would appreciate any insight anyone could give me. Thanks.

    http://cnyscouponing.staging.wpengine.com/test-post-amazon-deal-toys/
    January 4, 2014 at 7:10 am #83100
    Sridhar Katakam
    Participant

    Use this instead:

    add_filter( 'genesis_post_meta', 'sp_post_meta_filter' );
    function sp_post_meta_filter($post_meta) {
    
    	if ( !is_page() ) {
    		$post_meta = '[post_categories before="Categories: "] [post_terms taxonomy="store" before="Store: "]';
    		return $post_meta;
    	}
    }

    Source: http://my.studiopress.com/docs/shortcode-reference/


    Genesis Tutorials | Follow me on Twitter

    January 4, 2014 at 7:13 am #83101
    Sridhar Katakam
    Participant

    and just for kicks, if we were to do something similar using actions instead of a filter..

    //* Remove post meta from single Posts
    // add_action ( 'genesis_entry_content', 'sk_remove_post_meta' );
    function sk_remove_post_meta() {
    
    	if ( !is_singular('post' ) )
    		return;
    
    	remove_action( 'genesis_entry_footer', 'genesis_post_meta' );
    }
    
    //* Add custom post meta on single Posts
    // add_action( 'genesis_entry_footer', 'sk_post_meta' );
    function sk_post_meta() {
    
    	if ( !is_singular('post' ) )
    		return;
    
    	echo '<p class="entry-meta">';
    	echo do_shortcode('[post_categories]');
    	echo do_shortcode('[post_tags]');
    	echo the_terms( $post->ID, 'store', '<span class="entry-stores">Store: ', ' , ', '</span>' );
    	echo '</p>';
    }

    Genesis Tutorials | Follow me on Twitter

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘General Discussion’ 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

© 2025 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