Reputation: 21
I have implemented the WooCommerce shop on a custom page with their shortcodes.
The WooCommerce shortcodes have many attributes, but does not seem to not include something equivalent to: [show author="true"]
How can I work around this?
This is the code I have so far:
<?php echo do_shortcode ('[products limit="10" columns="3"]'); ?>
Even outside the shortcode implementation of WooCommerce, there seems to be few, if any alternatives to output the author name.
Would really appreciate help with this problem!
Upvotes: 1
Views: 1087
Reputation: 11282
You can use woocommerce_after_shop_loop_item_title
action hook check below code. code will go in your active theme functions.php file.
add_action( 'woocommerce_after_shop_loop_item_title', 'show_author_info_after_title', 2 );
function show_author_info_after_title() {
global $product; // global product object
$product_id = $product->get_id(); // product id
$author_id = get_post_field ('post_author', $product_id);
$product_author = get_the_author_meta( 'display_name' , $author_id );
echo '<p class="product-author">' . $product_author . '</p>';
}
Tested and works.
Upvotes: 1