Limit WordPress Post Revisions

Welcome mkmcst community Forum Web programming WordPress Random wordpress Limit WordPress Post Revisions

Viewing 0 reply threads
  • Author
    Posts
    • #8861
      Michael Mc
      Keymaster
      @mkmcst
      // Define your custom function
      function limit_post_revisions($num, $post) {
          // Set a max limit for revisions for all post types
          $max_revisions = 5;
      
          // Check if the post type is 'post'
          if ($post->post_type == 'post') {
              return $max_revisions;
          } else {
              return $num;
          }
      }
      
      // Hook into the 'wp_revisions_to_keep' filter
      add_filter('wp_revisions_to_keep', 'limit_post_revisions', 10, 2);
Viewing 0 reply threads
  • You must be logged in to reply to this topic.