我正在尝试构建一个具有供应商角色的用户滑块,并尝试从 dokan 插件获取供应商 url,这是我试图为滑块循环中的每个供应商生成链接但它不起作用:
function store_query_filter( $query ) {
global $wp_query;
$author = get_query_var( $query->custom_store_url );
if ( !is_admin() && $query->is_main_query() && !empty( $author ) ) {
$seller_info = get_user_by( 'slug', $author );
$store_info = dokan_get_store_info( $seller_info->data->ID );
if ( !empty( $store_info['store_name'] ) ) {
$vendor_link = dokan_get_store_url( $store_info->ID );
return $vendor_link;
}
}
}
add_shortcode( 'store_vendor_url', 'store_query_filter' );