[Support request] post archive entry meta footer – display custom taxonomies

Home Forums Support [Support request] post archive entry meta footer – display custom taxonomies

Home Forums Support post archive entry meta footer – display custom taxonomies

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1641064
    Craig

    Hello

    I’m using the standard posts and archive, but have some additional taxonomy terms I’d like to display like the ‘categories’ link below each post content in the archive page (entry meta footer).

    I have taxonomies for Actor / Writer / Subject / Style – created with Pods plugin FYI

    I have seen this forum post and have tried to use this php code – using the Snippets plugin – and changing ‘content-type’ to ‘actor’, but have been unsuccessful:
    https://generatepress.com/forums/topic/post-meta-for-custom-taxonomy-archives-and-category-archive/

    Here is an image to help show what I’m trying to do:
    https://drive.google.com/file/d/1HmcPf8rSQPLDlypTqXYUKpi0ji23eqAh/view?usp=sharing

    Thank you

    #1641711
    David
    Staff
    Customer Support

    Hi there,

    can you check that the ‘actor’ slug is correct ? Maybe PODs is outputting it differently

    #1668358
    Craig

    Hi David,

    Thanks, after some tinkering I was able to get this to work – I had to get singular and plural names in the right order/place.

    However I’ve now had to rethink how I structure the website and I’m looking at the WooCommerce option so we can take donations. I’m hoping it’s not too difficult to repurpose this code to work on the WooCommerce product archive template?

    Working code for post archive below:

    add_action( 'generate_post_meta_items', function( $item ) {
        if ( 'writers' === $item ) {
            $types = get_the_term_list( get_the_ID(), 'writer', '', ', ' );
    
            if ( $types ) {
                printf(
                    '<span class="taxonomy-links">%1$s%2$s | </span>',
                    apply_filters( 'generate_inside_post_meta_item_output', '', 'writers' ),
                    $types
                );
            }
        }
    } );
    
    add_action( 'generate_post_meta_items', function( $item ) {
        if ( 'actors' === $item ) {
            $types = get_the_term_list( get_the_ID(), 'actor', '', ', ' );
    
            if ( $types ) {
                printf(
                    '<span class="taxonomy-links">%1$s%2$s | </span>',
                    apply_filters( 'generate_inside_post_meta_item_output', '', 'actors' ),
                    $types
                );
            }
        }
    } );
    
    add_action( 'generate_post_meta_items', function( $item ) {
        if ( 'subjects' === $item ) {
            $types = get_the_term_list( get_the_ID(), 'subject', '', ', ' );
    
            if ( $types ) {
                printf(
                    '<span class="taxonomy-links">%1$s%2$s | </span>',
                    apply_filters( 'generate_inside_post_meta_item_output', '', 'subjects' ),
                    $types
                );
            }
        }
    } );
    
    add_action( 'generate_post_meta_items', function( $item ) {
        if ( 'styles' === $item ) {
            $types = get_the_term_list( get_the_ID(), 'style', '', ', ' );
    
            if ( $types ) {
                printf(
                    '<span class="taxonomy-links">%1$s%2$s</span>',
                    apply_filters( 'generate_inside_post_meta_item_output', '', 'styles' ),
                    $types
                );
            }
        }
    } );
    
    add_filter( 'generate_footer_entry_meta_items', function( $items ) {
        return array(
            'writers',
            'actors',
            'subjects',
    	'styles',
            'post-navigation',		
        );
    } );

    Thank you

    Craig

    #1668786
    David
    Staff
    Customer Support

    Ah Woocommerce has its own entirely different set of templates, with its own hooks. This article shows where all the Product Archive hooks are and what their current purpose are:

    https://www.businessbloomer.com/woocommerce-visual-hook-guide-archiveshopcat-page/

    So you could simply create your own template/function to get the author terms and hook them in place.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.