wp_update_post creating revisions instead of updating the post

check: https://codex.wordpress.org/Function_Reference/wp_update_post Make sure not to create an infinite loop. <?php function my_function( $post_id ){ if ( ! wp_is_post_revision( $post_id ) ){ // unhook this function so it doesn’t loop infinitely remove_action(‘save_post’, ‘my_function’); // update the post, which calls save_post again wp_update_post( $my_args ); // re-hook this function add_action(‘save_post’, ‘my_function’); } } add_action(‘save_post’, ‘my_function’); ?> … Read more

Custom Meta Box (SELECT2) Not Saving Taxonomy Terms

First of all you saved the the terms value in a post meta table and not following the wordpress conventional method. To make it connect with default category with that post you need to modify your save_post action. Check the modified code. add_action( ‘save_post’, ‘rudr_save_metaboxdata’, 10, 2 ); function rudr_save_metaboxdata( $post_id, $post ) { if … Read more

Why does wp_update_post causes white screen?

When commenting out wp_update_post( $post ), the update_post_meta is working fine. Yes, the problem is not with update_post_meta(), but it is wp_update_post() because it uses wp_insert_post() which fires the save_post_foglalas hook (i.e. save_post_<post type>), and because your function calls wp_update_post(), then your function gets called infinitely and eventually caused the White Screen Of Death (WSOD). … Read more

Update post title from external file?

Sometimes I use this code when I want to run WordPress externally. update.php function find_wordpress_base_path() { $dir = dirname(__FILE__); do { //it is possible to check for other files here if( file_exists($dir.”/wp-config.php”) ) { return $dir; } } while( $dir = realpath(“$dir/..”) ); return null; } define( ‘BASE_PATH’, find_wordpress_base_path().”https://wordpress.stackexchange.com/” ); define(‘WP_USE_THEMES’, false); global $wp, $wp_query, … Read more

Programmatically change post visibility on save_post action return a 500

There is some information about this problem in the Action Reference for save post: If you are calling a function such as wp_update_post that includes the save_post hook, your hooked function will create an infinite loop. To avoid this, unhook your function before calling the function you need, then re-hook it afterward. So something like … Read more

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