function append_text_to_product_title($title, $id) {
$text_to_append = ' - New Arrival'; // Your desired text to append
$title .= $text_to_append;
return $title;
}
add_filter('woocommerce_product_title', 'append_text_to_product_title', 10, 2);
Добавив этот код в файл options.php вашей темы, вы сможете добавить текст «Новое поступление» к каждому названию продукта.
function append_text_to_product_title($title, $id) {
if (is_product()) {
$text_to_append = ' - Limited Edition'; // Your desired text to append
$title .= $text_to_append;
}
return $title;
}
add_filter('the_title', 'append_text_to_product_title', 10, 2);
В этом коде текст «– Limited Edition» будет добавлен к названиям продуктов, если текущая страница является страницей продукта WooCommerce.
$product_id = 123; // Replace with your actual product ID
$text_to_append = get_post_meta($product_id, 'custom_text', true); // Retrieve the custom text from a custom field
$product_title = get_the_title($product_id); // Get the original product title
$new_product_title = $product_title . ' ' . $text_to_append; // Append the custom text to the product title
echo $new_product_title; // Output the modified product title
Сохранив пользовательский текст в настраиваемом поле, вы можете динамически добавлять его к названию продукта.
Внедрите эти методы сегодня и дайте своим продуктам WooCommerce импульс, необходимый для привлечения большего количества клиентов и увеличения продаж!