• I am using custom taxonomies that I created manually. I can make the list of taxonomies and terms appear above or bellow a post but not in it. I am playing with the idea of using shortcodes to add the tax terms within the post but I am not sure how to go about it. For example, adding [taxonomy] to the middle of a post and having all the post’s tax info appear right there!

    Currently, my tax info is displayed like so:

    <dl class="my-stats">
    <?php
    
    $terms_as_text = get_the_term_list( $post->ID, 'gender', '<dt>Gender:&nbsp</dt><dd>', ', ', '</dd>' ) ;
    echo strip_tags($terms_as_text, '<dt>,<dd>,&nbsp');
    
    $terms_as_text = get_the_term_list( $post->ID, 'age', '<dt>Age:&nbsp</dt><dd>', ', ', '</dd>' ) ;
    echo strip_tags($terms_as_text, '<dt>,<dd>,&nbsp');
    
    the_terms( $post->ID, 'location', '<dt>Loc:&nbsp</dt><dd>', ', ', '</dd>' );
    
    $terms_as_text = get_the_term_list( $post->ID, 'status', '<dt>Status:&nbsp</dt><dd>', ', ', '</dd>' ) ;
    echo strip_tags($terms_as_text, '<dt>,<dd>,&nbsp');
    
    the_terms( $post->ID, 'contact', '<dt>Contact:&nbsp</dt><dd>', ' or ', '</dd>' );
    
    ?>
    </dl>
    
    <?php the_content(); ?>

  • The topic ‘Display custom taxonomy output within posts’ is closed to new replies.