For each new post, I add News category.
And I want to delete this category from each post after 7 days.
I already know to "delete" the new category but how to run it every week ?
|
For each new post, I add And I want to |
||||
|
|
|
Did you try this plugin? http://wordpress.org/extend/plugins/scheduled-post-delete/ //// Sorry for my mistake, I understood you wrong. Try by pasting this in your functions.php:
What this will do is basically schedule event seven days after the post creation. On 7th day, remove_news_cat_func function will run that will remove "news" category from the list of categories assigned to that post. If you want to test it, you can change 604800 in wp_schedule_single_event to something like 30 and if you do that, 30 seconds after post creation category should be gone. Note that this function relies on WP-Cron so to fire it, someone actually has to visit the site (this might cause delay with short span of 30 seconds but with days you are fine). |
|||||||||||||||||
|
|
I found the solution. Thanks @OriginalEXE for the cron.
|
|||||
|