Skip to content

Instantly share code, notes, and snippets.

@gera3d
Created March 24, 2017 18:55
Show Gist options
  • Save gera3d/65996c659728f7d36c9f17d81dd4e6b0 to your computer and use it in GitHub Desktop.
Save gera3d/65996c659728f7d36c9f17d81dd4e6b0 to your computer and use it in GitHub Desktop.
Return a list of all 'product' taxonomy terms that are applied to.
$product_terms = wp_get_object_terms( $post->ID, 'product' );
if ( ! empty( $product_terms ) ) {
if ( ! is_wp_error( $product_terms ) ) {
echo '<ul>';
foreach( $product_terms as $term ) {
echo '<li><a href="' . get_term_link( $term->slug, 'product' ) . '">' . esc_html( $term->name ) . '</a></li>';
}
echo '</ul>';
}
}
@gera3d
Copy link
Author

gera3d commented Mar 24, 2017

I needed to change $post->ID to $post_object->ID so I could get data from the object vs the post.

@gera3d
Copy link
Author

gera3d commented Mar 24, 2017

replace product with testimonial-types to get what I needed to query.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment