Using str_replace filter in WooCommerce
-
I am trying to change some text on my WooCommerce Website.
Essentially, through a filter using the str_replace I’m trying to change the text ‘%s reviews for %s’ to be something else.
This text is included in the single-product-reviews.php file.
See below:
<h2><?php if ( get_option( 'woocommerce_enable_review_rating' ) === 'yes' && ( $count = $product->get_review_count() ) ) printf( _n( '%s review for %s', '%s reviews for %s', $count, 'woocommerce' ), $count, get_the_title() ); else _e( 'Reviews', 'woocommerce' ); ?></h2>
In order to do this I’m trying to use the following, but it doesn’t seem to work. I’m not sure what string I should be targetting.
function lnz_replace_content() { echo str_replace("%s reviews for %s","%s comments about %s", $product); } add_filter('init','lnz_replace_content');' Your help is much appreciated. Thanks in advance. Linz
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Using str_replace filter in WooCommerce’ is closed to new replies.