Site logo

Archived topic

post archive entry meta footer - display custom taxonomies

3 replies · Started by Craig on January 31, 2021

Viewing posts 1–4 of 4

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

Hi there,

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

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

This archived topic is closed to new replies.