0

I would like to have a custom post type which has 'Activate' and 'Deactivate' rather than 'Publish' and 'Move to Trash'. Once a post is deactivated, the user can go and delete it permanently.

This functionality is required due to the nature of the custom post type. Is it possible to disable the emptying of trash (by default 30 days) for this particular custom post type, so that the 'deactivated' posts will remain there and not be cleaned up?

1 Answer 1

1

If I understand your question correctly I just came across a similiar situation in a test project I'm working on.

I just added a custom meta field active and none active as a checkbox. When I get my posts on the pages I filter on this meta field aswell.

So on the live website I only show published posts who also have the custom checkbox active. If not I don't show them. But in the backoffice all those posts are threated as live posts.

Would this approuch be what you are looking for? If wanted I can provide some code examples, although this should be quite clear.

-- for trash you can do this. There is a constant named EMPTY_TRASH_DAYS you could Set EMPTY_TRASH_DAYS to a very high number.

 define( 'EMPTY_TRASH_DAYS', 1000000 );

btw this goes in your wp-config.php

I found this also here https://wordpress.stackexchange.com/a/7761/17541 seems like you can remove the shedule action.

function my_remove_schedule_delete() {
    remove_action( 'wp_scheduled_delete', 'wp_scheduled_delete' );
}
add_action( 'init', 'my_remove_schedule_delete' );
4
  • Yes this can also work, but adds an extra layer on top of the WordPress Published/Draft system, which I was hoping I could repurpose into Activated/Deactivated, exactly the way plugins work in WordPress.
    – urok93
    Commented Aug 20, 2012 at 13:17
  • Ok, I have no idea if you can hook into that functionality. I added a little more info about the trash situation to my answer above
    – woony
    Commented Aug 21, 2012 at 7:05
  • Removing scheduled delete would be nice, but I need to know if we can specify the deletion of that particular post type, rather than all deletions.
    – urok93
    Commented Aug 21, 2012 at 10:45
  • I do not think that will be possible. Your easiest solution remains my first suggestion I think.
    – woony
    Commented Aug 21, 2012 at 12:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.