Saving (Updating) Post / Page Edits With AJAX

The german (core) developer Dominik Schilling/ocean90 has released a pretty nice, simple and small plugin to encounter (part of) this problem. Instead of adding a complex AJAX save process, that would just make it harder to work with even handlers and such (de- & re-registering them), he just added a position marker, that allows WP … Read more

save_post + insert_post = infinite loop

This is because the first time you go round the loop $post is the current post. But the second time you go around the loop, $post has not changed. The same thing happens the 3rd, 4th, 5th, etc Because the $post variable is the current post of that page, not the post you’ve just saved/inserted, … Read more

get post meta before it is updated (during SAVE_POST)

save_post Runs whenever a post or page is created or updated, which could be from an import, post/page edit form, xmlrpc, or post by email. Action function arguments: post ID and post object. Runs after the data is saved to the database. above paragraph is quoted from WP Codex. so you cannot use this hook … Read more

Submitting posts from the front end – sanitizing data

When a post is created/edited from the admin, edit_post() is called. This function simply collects all the $_POST arguments and passes them to wp_update_post(). wp_update_post() then does some more logical checks and passes the data along to wp_insert_post(). wp_insert_post() calls sanitize_post(), which does all the heavy duty sanitization. So, yes, wp_insert_post() is the correct way … Read more

Disable the post save process completely

function disable_save( $maybe_empty, $postarr ) { $maybe_empty = true; return $maybe_empty; } add_filter( ‘wp_insert_post_empty_content’, ‘disable_save’, 999999, 2 ); Because wp_insert_post_empty_content is set to true, WordPress thinks there is no title and no content and stops updating the post. EDIT: An even shorter variant would be: add_filter( ‘wp_insert_post_empty_content’, ‘__return_true’, PHP_INT_MAX -1, 2 );

How to force function to run as the last one when saving the post?

add_action has a priority parameter which is 10 by default, you can increase that to load your function late. Change add_action( ‘save_post’, ‘do_custom_save’ ); to add_action( ‘save_post’, ‘do_custom_save’, 100 ); Now the priority is to set to 100 and will load quite late and will allow other function associated to load before this function is … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)