在Woocommerce的商店页面中添加商店标题

时间:2015-12-09 13:09:44

标签: php wordpress woocommerce

如何在Woocommerce的商店页面中显示产品标题后的产品供应商名称? 我尝试在 functions.php 文件的末尾添加此代码但不能正常工作!!

/**
 * Print the product's vendor name before the product title in the loop.
 *
 * @return void
 */
function wc_vendors_name_loop() {
	$vendors = get_the_terms( get_the_ID(), 'shop_vendor' );

	if ( $vendors && ! is_wp_error( $vendors ) ) {
		foreach ( $vendors as $vendor ) {
			$all_vendors[] = $vendor->name;
		}

		$vendors = join( ", ", $all_vendors );

		echo '<span class="shop_vendors">' . $vendors . '</span>';
	}
}
add_action( 'woocommerce_before_shop_loop_item_title', 'wc_vendors_name_loop', 20 );

0 个答案:

没有答案