Site logo

Archived topic

Display Custom Taxonomies on CPT Archive

3 replies · Started by Ryan on November 22, 2020

Viewing posts 1–4 of 4

Hey guys, I'm porting a theme from Genesis to GeneratePress. One small issue I'm having is styling my CPT Archive. I'm running the latest WordPress (5.3.3), Theme (3.0.2), and Plugin (1.12.2).

I have two CPT taxonomies, Sticker Method & Sticker Category, that I display with Genesis using their built-in [post_terms] shortcode. You can see it in action on my site here and this is the code I use in my themes functions to pull it off.

add_filter( 'genesis_post_meta', 'sticker_post_meta' );
function sticker_post_meta( $post_meta ) {
	if ( is_post_type_archive( 'hif_sticker' ) ) {
	   $post_meta = '<i class="fad fa-desktop" aria-hidden="true"></i> [post_terms taxonomy="sticker_signup" before="Method: "] ·
       <i class="fas fa-tags fa-flip-horizontal" aria-hidden="true"></i> [post_terms taxonomy="sticker_category" before="Category: "] ·
       <i class="fas fa-exclamation-triangle" aria-hidden="true"></i> <a href="//www.heyitsfree.net/report-freebie/?report_link=I+believe+this+sticker+is+dead+'. get_permalink() .'" rel="nofollow">Report a dead sticker</a>!';
	}
	return $post_meta;
}

I'm struggling to figure out the GP equivalent to display these custom taxonomies, either via function or GP hooks.

I tried the following code in a GP Hook, but it only output the term "Array" instead of the actual taxonomies, so I know I'm doing something wrong!

<i class="fad fa-desktop" aria-hidden="true"></i> Method: <?php echo get_terms('sticker_signup'); ?> ·
<i class="fas fa-tags fa-flip-horizontal" aria-hidden="true"></i> Category: <?php echo wp_get_post_terms('sticker_signup'); ?> · 
<i class="fas fa-exclamation-triangle" aria-hidden="true"></i> <a href="//www.heyitsfree.net/report-freebie/?report_link=I+believe+this+sticker+is+dead+'. get_permalink() .'" rel="nofollow">Report a dead sticker</a>

Thank you in advance for any help on this!

Cheers, thanks Tom. Using your tip, I was able to get this working with get_the_term_list!

Glad you got it working :)

This archived topic is closed to new replies.