Connect with us

Wordpress Tips

WordPress Tip: How to Delete/Hide Old Images

I don’t know about you but I cover a lot of exciting products on my tech website that become obsolete after a year or two. A lot of people prefer leaving old posts up but in certain cases, it may make sense to delete old images while leaving the posts up (e.g. copyright issues or companies going out of business). Here is a WordPress function that deletes images more than 3 years old automatically and hides them in posts they were used:

Currently Trending Themes

This takes care of your images but you need to hide old images. In this case, we are using the class “hide-image-image” in our PHP code. To hide it, you will simply have to use the following CSS rule:

This script only deletes posts that are older than 3 years old. You can modify it to target more recent images. In the tech world, 3 years is a life time. You do have the option to modify this to target only posts that have less than certain number of views if your theme has that option.

 

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.
You may also like...
Click to comment

Leave a Reply

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

More in Wordpress Tips

To Top