php - 变更单在 WooCommerce 中收到标题问题
问题描述
我有以下代码可以工作并更改“收到的订单”页面的标题:
add_filter( 'the_title', 'woo_title_order_received', 10, 2 );
function woo_title_order_received( $title, $id ) {
if ( function_exists( 'is_order_received_page' ) &&
is_order_received_page() && get_the_ID() === $id ) {
$title = "Thank you, good luck!";
}
return $title;
}
但是,由于Too few arguments to function woo_title_order_received()
. 上网查了一下,发现the_title
不对,应该是get_the_title
。如果我将其更改为致命错误消失,但它不再更改收到订单页面上的标题。
我在网上找到的其他片段都没有工作,我不明白为什么上面会阻止商店页面工作。有任何想法吗?
解决方案
尝试将$id
参数设置为null
(未定义时有用):
add_filter( 'the_title', 'woo_title_order_received', 10, 2 );
function woo_title_order_received( $title, $id = null ) {
if ( function_exists( 'is_order_received_page' ) &&
is_order_received_page() && get_the_ID() === $id ) {
$title = "Thank you, good luck!";
}
return $title;
}
它可以工作......</p>
推荐阅读
- python - 在 PyQt5 中删除小部件时如何删除黑色空间
- system-verilog - SystemVerilog 中队列的最大大小是多少?
- node.js - Traefik 仍然需要端口规范
- excel - 如何在工作簿中搜索字符串然后将其写入同一行的列中?
- php - Laravel 调度程序和 docker cron
- excel - 使用 Excel 溢出范围作为递归 Lambda 函数的数据源
- python - 可以重建 2d 矩阵,其中掩码已与 numpy where 一起使用并展平
- makefile - 如何让 make 运行使用 make 变量在其中创建 azure 服务主体的命令
- java - 如何从 EAR 中存在的战争中排除 jar 文件
- python - 如何编写没有节的ini文件?