[Support request] Display Custom Taxonomy in Post Meta Nav

Home Forums Support [Support request] Display Custom Taxonomy in Post Meta Nav

Home Forums Support Display Custom Taxonomy in Post Meta Nav

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #489112
    Satori

    Some weeks ago Tom provided the code to display the meta nav on my CPT entries. I need to display also the custom taxonomy, hope you can help me with the code.

    I’ve noticed this code only works on the actual post, there is away to show this also in the archive page?

    GeneratePress 2.0.2
    GP Premium 1.5.6
    #489607
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Can you share the latest code you’re using in here? I may be able to extend it to include taxonomies and show on archives.

    Let me know 🙂

    #489707
    Satori

    Thanks Tom! That would be awesome. Here is the code:

    add_action( 'generate_after_entry_content', 'tu_cpt_footer_meta' );
    function tu_cpt_footer_meta() {
        if ( is_singular( 'your-post-type' ) ) : ?>
            <footer class="entry-meta">
                <?php generate_entry_meta(); ?>
                <?php generate_content_nav( 'nav-below' ); ?>
            </footer><!-- .entry-meta -->
        <?php endif;
    }
    #490103
    Tom
    Lead Developer
    Lead Developer

    I believe you would have to do this:

    add_action( 'generate_after_entry_content', 'tu_cpt_footer_meta' );
    function tu_cpt_footer_meta() {
        if ( is_singular( 'your-post-type' ) || is_post_type_archive( 'your-post-type' ) ) : ?>
            <footer class="entry-meta">
                <?php generate_entry_meta(); ?>
                <?php generate_content_nav( 'nav-below' ); ?>
    
                <?php
                $term_list = wp_get_post_terms( get_the_ID(), 'your_custom_taxonomy_slug', array("fields" => "all"));
                foreach ( $term_list as $term_single ) {
                    echo $term_single->slug;
                }
                ?>
            </footer><!-- .entry-meta -->
        <?php endif;
    }
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.