1

I am replacing the sales badge on the woocommerce products page with an image. I have succesfully done this by adding the following to my functions.php

add_filter('woocommerce_sale_flash', 'vs_change_sale_content', 10, 3);
function vs_change_sale_content($content, $post, $product){
   $content = '<span class="onsale"><img src="http://localhost:8888/marmalade/wp-content/uploads/2018/01/in-stock.png"></span>';
   return $content;
}

This, however, uses a hardcoded url for the image. How can I replace the source with my theme folder? So that when I change servers The url is still correct.

0

Change your image url to "/wp-content/uploads/2018/01/in-stock.png"

That way even if you change servers (or changed domain name), as long as the filepath doesn't change from wp-content, you'll still be safe.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.