-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreal-woocommerce-author.php
More file actions
49 lines (38 loc) · 1.18 KB
/
real-woocommerce-author.php
File metadata and controls
49 lines (38 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
/**
* @package real-woocommerce-author
* @version 1.0.0
*/
/*
Plugin Name: Real WooCommerce Author
Plugin URI:
Description: Displays the author taxonomy into products
Author: RealCodeLab
Version: 1.0.0
Author URI: http://realcodelab.com/
*/
if (! defined('ABSPATH')) {
exit; // Exit if accessed directly
}
add_action('woocommerce_single_product_summary', 'show_product_author_after_title_on_single_product', 6);
/**
* Show the taxonomy product_author after the title of single products.
*/
function show_product_author_after_title_on_single_product()
{
global $product;
$product_id = $product->get_id();
// Get the terms
$product_authors = wp_get_post_terms($product_id, 'product_author');
if (! empty($product_authors)) {
$output = array();
// Add a link to each term
foreach ($product_authors as $term) {
$link = get_term_link($term, 'product_author');
$output[] = sprintf('<a href="%s" rel="author">%s</a>', $link, $term->name);
}
$output = implode(', ', $output);
// Echo the list of term links (authors)
echo '<div class="product-author">por ' . $output . '</div>';
}
}