Hot answers tagged

17

When you register your CPT, you need to manually add support for revisions. Only title and editor are set as defaults. Check out the codex. So if you need to enable revisions, you need to add it like this 'supports' => array( 'title', 'editor', 'revisions' ), in your $args = array() when registering your CPT. Just for info, here are the other arguments ...


7

This should be placed in your wp-config.php (and no where else): define( 'AUTOSAVE_INTERVAL', 60*60*60*24*365 ); // autosave 1x per year define( 'EMPTY_TRASH_DAYS', 0 ); // zero days define( 'WP_POST_REVISIONS', false ); // no revisions


7

If you don't have control over the post type registration, you an use the remove_post_type_support() function: add_action('admin_init', 'disablew_revisions'); function disable_revisions(){ remove_post_type_support('post', 'revisions'); } If you also wish to disable autosave for specific post types, you can do this: add_action('admin_print_scripts', '...


6

Michael Adams, Quantum Bug Creator at Automattic once said: "Revisions are stored in the posts table. I don't yet know what kind of impact that will have on post queries. We're going to turn the switch to "on" on WordPress.com sometime soonish and we'll have a better idea about what kind of damage, if any, it does." And sometime later they did ...


6

This is a much safer query to use and will remove related entries from the postmeta and term_relationship, unlike deathlocks query in his answer. Change the {id} to the id of each blog posts table. You can combine this query to run all the post tables at once, but try this on one table first. I've used it many times on single WP installs. DELETE a,b,c FROM ...


5

Unfortunately, there is no standardized best practice instituted by WordPress for hooking into Backbone templates. There have been plans suggested to bring the familiar filters and actions API to Javascript in WordPress, but there is a lack of traction in this movement. Carl Danley created a library which does just that, which is helpful if you're trying to ...


5

I'm not one-hundred percent sure, what is failing for you, but I can tell you, generally it should work. The proof is following under thirdly. Before I have some remarks for you: Firstly, my guess would be, that it indeed isn't failing silently, but while doing an AJAX process. So make use of a tool like FireBug to take a closer look at that. Secondly, I'm ...


4

Is it safe to directly delete all rows in the wp_posts table that have a post_type of revision? (I've seen conflicting answers on this—but I'd love to be able to just do it this way if it's safe) Safe, it's safe. If there is only one user (you) that can edit posts on site it's safe and does not bring any other problem. If there are more, and one is ...


4

I just wasted a lot of time figuring this out. There are number of things a user should rule out first. Deactivate any plugins and switch to a default theme like twenty-thirteen if the below items do not work. To make sure that you don't have revisions turned off, be sure this does not exist in wp-config.php: define('WP_POST_REVISIONS', false); While on a ...


4

Try the_modified_author() or get_the_modified_author(), this should give you the display name of the last user that modified the post.


4

Revisions to me are useless and just fills up your db. It might be useful to others though. Revisions are created each time a post is revised/updated. This just holds an archive/copy of the post before it was updated, and gives the user an option to restore the specific post to an earlier time. This works exactly like any system with a restore button. If ...


3

It all depends on your workflow. If you have no use for the post revisions and autosaves then disable them in wp-config and WordPress will clean them up on its own. You may also prefer to limit how many you keep at once. Also the space they take up is unlikely to be of a great impact itself unless you're running on a tiny tiny server Don't go deleting them ...


3

Every time you edit a post/page, WordPress creates timely revisions of it. Check the Firebug console for the requests that are sent at regular intervals when you are on the edit page. They are useful if you lose the post content at some point and want to get back to an earlier version of the post. Once you publish the final version of the post then you can ...


3

Remove the revisions property inside the supports parameter of register_post_type(). Example $args = array( // ... 'supports' => array('title','editor','thumbnail','comments','revisions') ); register_post_type('book',$args); Change to: $args = array( // ... 'supports' => array('title','editor','thumbnail','comments') ); ...


3

I might be wrong, but my first guess would be that this is not easily possible, because number of revisions gets saved into constant and does not seem hook-able. From quick search relevant checks are in wp_save_post_revision() and it's very rigid.


2

Set custom autosave interval Just define it in your wp-config.php file // Allow revisions define( 'WP_POST_REVISIONS', true); // Set number of ms define( 'AUTOSAVE_INTERVAL', 300 ); Note that this means that you'll get a lot of queries and post revisions. Therefore you should also add a max. number of revisions to not fill your posts table with stuff you ...


2

It took me a while but I got it! This works as follows: Since you have no reference to the post other than the URI, we segment out the URI to check for a page with that page_name If there is a page, we get the latest revision child Hack the query to force our revision slug to source the page This works swell because it gives the appearance of a working ...


2

There is also a plugin, WP Optimize that can help you do this From the website: WP-Optimize is a WordPress 2.9++ database cleanup and optimization tool. It doesn't require PhpMyAdmin to optimize your database tables. It allows you to remove post revisions, comments in the spam queue, un-approved comments within few clicks.


2

you can grab revisions from wpdb with smth like $revisions = $wpdb->get_results("select * from {$wpdb->posts} where post_parent={$post_id} and post_type='revision'") after selecting a revision you could use some js diff tool like http://cemerick.github.io/jsdifflib/demo.html


2

Probably is a way with an SQL query. But another solution is to use Search RegEx, which is a good plugin to be able to search and replace with grep and regular expressions through all posts and pages. And I'd delete all your revisions to make sure the links aren't hidden in old revisions that might get restored at some point. If you need to develop a regex ...


2

I've often thought this would make a good feature, though I've never seen a plugin for it. I think the term "comment" is probably throwing off your search. I wouldn't think that this would be stored as a comment internally, but rather as metadata for the post. I did a search for plugins using the term "revision description" instead of revision comment, and I ...


2

You can use wp_get_post_revisions ( int|WP_Post $post_id, $args = null ). It returns an array of revisions for the passed post ID or an empty array if a passed post does not have any revisions. Note that the $args parameter accepts all parameters valid for WP_Query $q = wp_get_post_revisions( 513 ); echo count( $q ); ?><pre><?php var_dump($q);...


2

You can try the wp_revisions_to_keep filter to override the value of the WP_POST_REVISIONS constant: /** * Turn off revisions */ add_filter( 'wp_revisions_to_keep', function( $num, $post ) { //--------------------------------- // Adjust the $num to your needs //--------------------------------- if ( post_type_supports( $post->post_type, ...


2

No, that isn't normal for 23 posts. Note that "posts" is pretty wide concept in modern WordPress. Many things are posts without being obvious as such, for example parts of navigation menus. While 60k entries does sound excessive for a small site, there is no telling without examining actual data to determine which post types it belongs to and if those ...


1

If you remove revisions, your blog is going to be identical for the user. Only in the backend, you won't have access anymore to your post history. You can also use plugins like https://wordpress.org/plugins/wp-optimize/ to do that. Ref: http://codex.wordpress.org/Post_Types#Revision


1

You can prevent more than three revisions from being saved to the database in the future by adding this line to your wp-config.php file: define( 'WP_POST_REVISIONS', 3 ); That line should limit new posts to three revisions, but it won't go through your database and clean it up. The SQL snippet that you found for deleting old revisions from the WordPress ...


1

Run SQL query: DELETE FROM wp_posts WHERE post_type = "revision" // for "wptest" DB, note the table name NOTE: The above query “just deletes post marked as revisions. If for some reason you associated a revision with a tag or a category that was then removed when the final post was published, you will have extra entries in other tables such as terms.” The ...


1

To address: What will happen to these posts if I set WP_POST_REVISIONS to 10? Will old versions be deleted automatically, or will they remain? You have this action: add_action( 'pre_post_update', 'wp_save_post_revision' ); set by default in /wp-includes/default-filters.php. If you check the source of wp_save_post_revision() you can see that it ...


1

You should set WP_POST_REVISIONS to a fixed number. If you don’t, WordPress will keep an unlimited number of revisions. See function wp_revisions_to_keep(): function wp_revisions_to_keep( $post ) { $num = WP_POST_REVISIONS; if ( true === $num ) $num = -1; else $num = intval( $num ); if ( ! post_type_supports( $post->...


1

Your question specifies that you are looking for 'suggestions' so this answer is in that category rather than in the 'working code' category. I am going to start by saying that I don't know if this is a good idea. You are going to multiply the size of your database many times over. Now that is off my chest, if you are going to proceed here are my thoughts. ...



Only top voted, non community-wiki answers of a minimum length are eligible