How to check if a page is older than say 30 days? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to check if a page is older than say 30 days?

I know it's possible check if a post is a specific age, but I would like to do the same with a page in WordPress, to see if the page is older than 30 days, then trigger code... if ( page_age(30) ) { // Archive the page, hide it from visitors } else { // Keep it listed and available to visitors }

13th Feb 2017, 1:03 PM
Andre van Rensburg
Andre van Rensburg - avatar
2 Answers
0
save time when page is published. then subtract it with current time... var days = new Date(older-current); var daysOld = days.getDay(); if(dayOld>30) return true;//30 days complete else return false;
14th Feb 2017, 8:45 AM
Pankaj Vaghela
Pankaj Vaghela - avatar
0
if you want for some reason sql command since you tagged sql select * from poststable where postdate<'year-mm-dd'; where posttable is table where posts are kept and postdate is column with post date :)
17th Feb 2017, 6:45 PM
Nemanja Jovanović
Nemanja Jovanović - avatar