Php 未找到产品时更改搜索框中的文本

Php 未找到产品时更改搜索框中的文本,php,wordpress,woocommerce,hook-woocommerce,Php,Wordpress,Woocommerce,Hook Woocommerce,我正在用WooCommerce开发一个WordPress网站,搜索框显示“找不到产品”。当产品不可用时显示文本 如何将此文本更改为其他内容“别担心,稍后再试” 我不知道如何处理这个问题,因为我对这种修改非常陌生。您可以使用gettext钩子来更改文本 使用开关将其放在functions.php中,将只影响“woocommerce”文本域中的文本 函数dd\u change\u text\u字符串($translated\u text,$text,$domain){ 开关($translated

我正在用WooCommerce开发一个WordPress网站,搜索框显示“找不到产品”。当产品不可用时显示文本

如何将此文本更改为其他内容“别担心,稍后再试”


我不知道如何处理这个问题,因为我对这种修改非常陌生。

您可以使用
gettext
钩子来更改文本

使用开关将其放在functions.php中,将只影响“woocommerce”文本域中的文本

函数dd\u change\u text\u字符串($translated\u text,$text,$domain){
开关($translated_text){
案例“未找到产品”:
如果($domain=='woocommerce'){
$translated_text=uuuuuu(“别担心,稍后再试”,“woocommerce”);
}否则{
$translated_text=uuu('No products found',$domain);
}
打破
}
返回$translated_text;
}
添加过滤器('gettext','dd_change_text_strings',20,3);

我甚至更改了$domain的“未找到任何产品”,但它仍然不起作用。我也清除了缓存,但是$translated=str_replace('No products found','New Message',$translated)仍然有效;
add_filter( 'woocommerce_register_post_type_product', 'woocommerce_register_post_type_product' );

function woocommerce_register_post_type_product( $labels ) {
    $labels[ 'labels' ][ 'not_found' ] = __( 'don\'t worry, try again later', 'woocommerce' );
    return $labels;
}