Answer the question
In order to leave comments, you need to log in
How to delete certain posts every week, two weeks in worpdress?
How to delete certain posts every week, fortnight in worpdress? How to write an algorithm correctly. Task: when creating a post, there is a select (One week, two weeks) after which time the publication should be deleted.
Answer the question
In order to leave comments, you need to log in
I do the opposite:
when creating a post with a select with a "lifetime" (a week, 2 weeks, etc.),
I generate the values in this select as "time now" + 1 week, 2 weeks, etc., I
attach the resulting numbers in the meta field,
then either hang function to open each post, compared the current time with this meta field (if more, I delete the post or archive it).
or as a separate cron task I'm looking for posts with a meta field greater than "current time"
designate the date as - the time of deletion as a column in your table.
then add crowns with the WP function, or in pure php with similar sql:
Just keep in mind that if you have posts that obviously cannot be deleted, then you need to either add a field to them, or write down a very big date ahead.
Why doesn't WordPress have a "publish end time" feature?
I don't work with it, but any self-respecting admin panel has it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question