[英]Woocommerce - get product author's email address
我正在努力寻找如何从Woocommerce获取产品作者的电子邮件地址。
我正在尝试:
<?php
global $post, $product;
$author_email = get_the_author_meta( 'email', $product->post->post_author );
return $author_email;
?>
但这似乎并不正确
正确的meta是user_email
而不是email
<?php
global $post, $product;
$author_email = get_the_author_meta( 'user_email', $product->post->post_author );
return $author_email;
?>
检查该功能,将其粘贴在function.php上
add_filter('post_type_link', 'add_author_id', 10, 4);
function add_author_id($post_link, $post, $leavename, $sample) {
if ('product' != get_post_type($post))
return $post_link;
$authordata = get_userdata($post->post_author);
$author = $authordata->id;
$post_link = str_replace('%author%', $author, $post_link);
return $post_link;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.