I have the following code which works and changes the title of the ‘order received’ page:
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;
}
However it causes a fatal error on the shop page due to Too few arguments to function woo_title_order_received()
. After checking online I found that the_title
isn’t correct and it should be get_the_title
. If I change it to that the fatal error goes away, but it no longer changes the title on the order received page.
None of the other snippets I’ve found online have worked, and I can’t see why the above stops the shop pages from working. Any ideas?
2
Answers
No idea why you should use
the_title
WordPress hook with multiple if conditions, while WooCommerce has specific hooks for that.The
'woocommerce_endpoint_' . $endpoint . '_title'
filter hook allows to change theOrder received
title.So you get:
Try to set
$id
argument tonull
(useful when it’s not defined):It could work…