我在function.php中使用以下代码,以使用简码在产品卡上显示商店名称和头像。它工作正常,但是当我尝试使用Elementor编辑页面时出现此错误:无法加载elementor预览。
我的简码有什么问题吗?
add_shortcode( 'dokan_vendor_name', 'dokan_store_name_shortcode' );
function dokan_store_name_shortcode() {
global $product;
$seller = get_post_field( 'post_author', $product->get_id());
$author = get_user_by( 'id', $seller );
$vendor = dokan()->vendor->get( $seller );
$store_user = dokan()->vendor->get( $author );
$store_info = dokan_get_store_info( $author->ID );
if ( !empty( $store_info['store_name'] ) ) { ?>
<div class="olkos-archive-product-card-author">
<img src="<?php echo esc_url( $store_user->get_avatar() ) ?>">
<div>
<p>Créateur</p>
<p><?php printf( '<a href="%s" style="color:#000;">%s</a>', $vendor->get_shop_url(), $vendor->get_shop_name() ); ?></p>
</div>
</div>
<?php
}};