Skip to content

Instantly share code, notes, and snippets.

@farookibrahim
Created April 20, 2016 06:24
Show Gist options
  • Select an option

  • Save farookibrahim/ab39f043d6a9a40efb31526c1a53352c to your computer and use it in GitHub Desktop.

Select an option

Save farookibrahim/ab39f043d6a9a40efb31526c1a53352c to your computer and use it in GitHub Desktop.
Unicase Author Attribute Display on Single Product Page
<?php
if ( ! function_exists( 'uc_custom_product_single_author_info' ) ) {
function uc_custom_product_single_author_info() {
global $product;
$product_id = isset($product_id) ? $product_id : $product->id;
$terms = get_the_terms( $product_id, 'author' ); // Taxonomy Slug of Created Author Attribute
$author_info = '';
if ( $terms && ! is_wp_error( $terms ) ) {
foreach ( $terms as $term ) {
$author_info .= '<a href="' . esc_url( get_term_link( $term ) ). '"><span>' . esc_attr( $term->name ) . '</span></a>';
}
}
if ( ! empty( $author_info ) ) : ?>
<div class="author-info">
<?php echo wp_kses_post( $author_info ); ?>
</div>
<?php endif;
}
}
add_action( 'woocommerce_single_product_summary', 'uc_custom_product_single_author_info', 7 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment