Z
Z
Zhandev2016-03-27 12:22:23
MySQL
Zhandev, 2016-03-27 12:22:23

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

4 answer(s)
D
Dmitry, 2016-03-27
@Zhandev

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"

D
Dmitry Bay, 2016-03-27
@kawabanga

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.

S
Sergey Goryachev, 2016-03-27
@webirus

Why doesn't WordPress have a "publish end time" feature?
I don't work with it, but any self-respecting admin panel has it.

S
sl1m_dogg, 2016-03-27
@sl1m_dogg

I agree, either by cron through the base, or by cron using the vp function, well, or nodges

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question