In WooCommerce, The "No products were found matching your selection." text appears when no products are found in the loop.
However, I want to add HTML in the text, so I use the gettext filter hook. Via str_ireplace I can easily overwrite the text:
function change_empty_category_text($translated) {
$translated = str_ireplace ('No products were found matching your selection.', 'sorry! we are not delivering products from this category to you pin code at the moment.', $translated);
return $translated;
}
add_filter( 'gettext', 'change_empty_category_text' );
However, when I want to add HTML in this text:
function change_empty_category_text($translated) {
$translated = str_ireplace ('No products were found matching your selection.', 'sorry! we are not delivering products from this category to you pin code at the moment.\r\nplease visit the following categories instead\r\n<a href = 'www.example.com/category1'>category 1</a>\r\n<a href = 'www.example.com/category2'>category 2</a>\r\n<a href = 'www.example.com/category3'>category 3</a>', $translated);
return $translated;
}
add_filter( 'gettext', 'change_empty_category_text' );
It has no result. Instead, I am getting the same exact text as written in the replacement.
Any advice?