Connect with us

Wordpress Tips

How to: Hide All Old Images in WordPress without Deleting Them Using functions File

Most of us have a lot of old images on our website that are outdated or need to be removed for some reason. You can try to do it manually but that can take a lot of effort. If you just delete them without removing their links in your posts, it could affect user experience. The good news is you can use your functions file to do it.

🛠️ Divi Builder drag & drop page builder for WP

The idea here is simple: you will have to create a class that hides images. Your function should also apply them to IMG elements in your posts. You will want to make sure your function only targets posts that are too old. This code snippet also makes sure only posts are targeted and not pages. Just add this to your functions file and change the date. This particular code hides images posted before August of 2024.

 

Continue Reading
You may want to check out:
*some of our articles and lists include affiliate links to fund our operations (e.g. Amazon, Elegant Themes, Envato). Please read our disclaimer on how we fund Exxponent.
Click to comment

Leave a Reply

Your email address will not be published. Required fields are marked *

More in Wordpress Tips

To Top