Add flag image to product title for specific product ID

This commit is contained in:
2025-04-11 17:53:28 +02:00
parent d9c2d0ebf2
commit 129c1af947

View File

@@ -1176,7 +1176,12 @@ if ( ! function_exists( 'woocommerce_template_loop_product_title' ) ) {
* Show the product title in the product loop. By default this is an H2.
*/
function woocommerce_template_loop_product_title() {
echo '<h2 class="' . esc_attr( apply_filters( 'woocommerce_product_loop_title_classes', 'woocommerce-loop-product__title' ) ) . '">' . get_the_title() . '</h2>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
$product_id = get_the_ID();
if ( $product_id == 787 )
$img = '<img src="https://biologikasukcesji.pl/wp-content/uploads/2025/04/flag-english.png" alt="English" style="height: 20px; margin: 0 5px 0 0; position: relative; top: 4px;" />';
else
$img = '';
echo '<h2 class="' . esc_attr( apply_filters( 'woocommerce_product_loop_title_classes', 'woocommerce-loop-product__title' ) ) . '">' . $img . get_the_title() . '</h2>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
}
if ( ! function_exists( 'woocommerce_template_loop_category_title' ) ) {