• 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

Display taxonomy description with Genesis shortcode

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 › Display taxonomy description with Genesis shortcode

This topic is: resolved

Tagged: custom taxonomy, show taxonomy description, taxonomy, taxonomy description

  • This topic has 3 replies, 2 voices, and was last updated 12 years, 10 months ago by asterbird.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • February 7, 2013 at 9:52 pm #18847
    asterbird
    Member

    I have a custom taxonomy called 'attractions' with description field that normally doesn't show up on the frontend.

    How do I display this?

    I am using this Genesis shortcode in my theme's functions.php to display the taxonomy:

    add_filter( 'genesis_post_meta', 'display_attractions_taxonomy' );
    function display_attractions_taxonomy($post_meta) {
    $post_meta = '[post_terms before="Nearby Attractions: " taxonomy="attractions"]';
    return $post_meta;
    }
    

    Now how do I display the description along with it? I scoured the WP / Genesis forums, but can't figure out what I'm looking for. Any tips in the right direction are greatly appreciated!

    February 8, 2013 at 2:53 am #18886
    vajrasar
    Member

    Read this, it may help you -

    http://wpmu.org/how-to-display-your-wordpress-category-description-in-your-theme/


    I make WordPress websites using Genesis Framework.

    WordPress/Genesis Development | Customizations

    February 8, 2013 at 8:06 am #18921
    asterbird
    Member

    @vajrasar,  thanks! that was a great article, but I'm not sure if it works for custom taxonomies.

    I am able to display the description nicely using the following code in my theme functions.php file.

    /**
    * Sarah Edit - Customize the post meta function
    */
    add_filter( 'genesis_post_meta', 'sarah_attractions_meta' );
    function sarah_attractions_meta( $mix_venue ) {
    $terms = get_terms( "attractions" );
    $count = count($terms);
    if ( $count > 0 ) {
    echo "Attractions Near " . get_the_title(); // post title for heading
    foreach ( $terms as $term ) {
    echo "<li>";
    // taxonomy title with custom link to its single page
    echo "<a href='" . home_url() . "/attractions/" . $term->slug . "' title='See " . $term->name . " - an attraction nearby'>" . $term->name . "</a>";
    echo "<br>";
    echo "<span>" . $term->description . "</span>";
    echo "</li>";
    }
    }
    }
    

    However, this displays all the attractions, not just the ones associated with the post. Maybe I should do a loop? I'm not sure how to do that.

    February 8, 2013 at 9:32 am #18933
    asterbird
    Member

    This works now.  I found the code here, and customized it.

    Now it echos the list of terms (for a taxonomy called attractions) associated with the post.

    
    add_filter( 'genesis_post_meta', 'sarah_attractions_meta' );
    function sarah_attractions_meta( ) {
    
    $terms = get_the_terms( $post->ID, 'attractions' );
    
    if ( $terms && ! is_wp_error( $terms ) ) :
    
    $attraction_terms = array();
    
    echo "<h4>Attractions Near " . get_the_title() . "</h4>";
    
    foreach ( $terms as $term ) {
    echo '<li><a href="' . get_term_link($term->slug, 'attractions') . '">' . $term->name . '</a></li>';
    echo '<li>' . $term->description . '</li>';
    }
    
    $attractions = join( ", ", $attraction_terms );
    endif;
    }
    
    
  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Display taxonomy description with Genesis shortcode’ is closed to new 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