Autosave control in WordPress

Autosave: Autosave is simply about saving your posts automatically in the background while you are editing. So it’s different from revisions and for every post there will be only one autosave per user. This is from the document: There is only ever a maximum of one autosave per user for any given post. New autosaves … Read more

Is it possible to select against a post’s parent’s fields with WP_Query?

You should use posts_join and posts_where filters to modify JOIN and WHERE clauses. add_filter( ‘posts_join’ , ‘se333659_posts_join’, 20, 2 ); add_filter( ‘posts_where’ , ‘se333659_posts_where’, 20, 2 ); function se333659_posts_join( $join, $query ) { global $wpdb; if ( isset($query->query_vars[‘_rev_of_publ’]) && $query->query_vars[‘_rev_of_publ’] == ‘1’ ) { $join .= ” LEFT JOIN {$wpdb->posts} AS rev_p ON ({$wpdb->posts}.post_parent = … Read more

Is there a way to get a revision count of a post?

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 ); … Read more

Adding revision support to WooCommerce product content

As you pointed out already there is a filter. add_filter( ‘woocommerce_register_post_type_product’, ‘wpse_modify_product_post_type’ ); function wpse_modify_product_post_type( $args ) { $args[‘supports’][] = ‘revisions’; return $args; } Put that in your child theme’s functions.php file.

revert one revision of a post progmattically via code?

So via lots of head banging and experimentation I managed to get a solution to letting editors/admins review the post whilst a previous one stays live is rather convoluted but does work. The key thing I did was to create a new post status which I call awaiting. In the admin it appears as “changes … Read more