Hide content editor for posts after approriate date

I am tuning my new site and i what to disable Content Editor for post created after date X, but for posts that created before that date Content Editor must be on its place.

Related posts

1 comment

  1. function disable_editor_for_old_posts_wpse_101106($post) {
      if (strtotime('-2 months') > strtotime($post->post_date)) {
        remove_post_type_support('post','editor');
      }
    }
    add_action('add_meta_boxes_post', 'disable_editor_for_old_posts_wpse_101106');
    

    I couldn’t find a great hook for this but add_post_meta_boxes_* is early enough, and it passes the $post object to the callback.

    Basically the filter checks the post on the post edit screen and removes post type support based on the post age. I used two months as the cutoff but that is easily altered.

    I don’t see the point of worrying about the editor except on the backend, unless you have a front-end posting mechanism.

    Removing the editor makes the page a bit ugly, but I think that adding some kind of message meta box via edit_form_after_title would sort that out– as done here: https://wordpress.stackexchange.com/a/100495/21376

    Reference

    http://codex.wordpress.org/Function_Reference/remove_post_type_support

Comments are closed.