Learn in this tutorial how to modify the placeholder image used by WooCommerce on products without featured image using code.
If you are used to using WooCommerce you will have noticed that when a featured image is not added to a product, it displays one by default:
But you might want to change it to another one.
For example, if you have a mug store, it probably makes more sense to show the following image, since it is more specific.
And here’s how to get it:
Snippet to customize the default image of WooCommerce products
Add the following code at the end of functions.php or in your functionality plugin:
To see this and another 1097 code snippets of this website, login or subscribe here.
Thanks to the woocommerce_placeholder_img_src
filter you can indicate the path of the image you want to use as placeholder or default image.
Just upload the image you want to use, if you haven’t already, and modify the path in the $src
line (only the final part '/2022/04/placeholder.svg'
).
Conclusion
As you can see, with a few lines of code you can customize the default image that WooCommerce uses for products where you have not selected a featured image.
Any questions? Let me know in the comments.
And if you want to give me any suggestion for future tutorials, leave it in the contact form. Advantages of being a subscriber. 😉