【发布时间】:2017-12-08 21:12:59
【问题描述】:
我正在使用 woo commerce 和 WC Vendor 插件来创建供应商商店。现在我想要产品作者 ID 以及 woo 商业产品的永久链接中的任何人都知道如何做到这一点。
提前致谢
【问题讨论】:
标签: wordpress woocommerce wordpress-theming
我正在使用 woo commerce 和 WC Vendor 插件来创建供应商商店。现在我想要产品作者 ID 以及 woo 商业产品的永久链接中的任何人都知道如何做到这一点。
提前致谢
【问题讨论】:
标签: wordpress woocommerce wordpress-theming
我通过在functions.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;
}
【讨论】: