Scheduling posts to update once per day with wp_cron

This is a typical example of an X-Y problem. Your cron is fine. Your logic not so. You have a function that hooks into save_posts and you think that passing the array $update = array( ‘ID’ => get_the_ID() ) will trigger the action and so your post will update the taxonomy. That’s incorrect, unfortunately. Passing … Read more

Wp_update_post: Infinite loop even with remove_action solution, OOP

You need to match the $priority you used to hook the action: remove_action( ‘save_post’, array( $this, ‘save_box’ ), 20 /* Same as add_action call */ ); http://codex.wordpress.org/Function_Reference/remove_action Make sure you take the $post_id argument in your save_box method too: function save_box( $post_id ) { … }

Custom function to rearrange attachments when creating posts – Almost there

I’m not entirely sure what your intentions are for the code, and unfortunately i didn’t find what you provided worked very well, so i rewrote parts of the code supplied to make it into a more workable solution. This code will work for saving the attachment order in the metabox on save, not via ajax, … Read more

Which action hook can I use when a featured image has been selected

The set_post_thumbnail function uses the metadata functions to set the featured image. You have two actions to hook into that process: EDIT: The action hooks are now defined different Thanks @dalbaeb! update_postmeta, before the data is written into the database. Previously update_post_meta updated_postmeta, after the data is written into the database. Previously updated_post_meta SECOND EDIT: … Read more

What are the limitations of wp_update_post()?

You are correct; WordPress will not update custom database columns using wp_update_post() or wp_insert_post(). Instead of creating custom database columns, consider using post meta and/or taxonomy APIs. If you must altar the wp_posts table, you will need to update your custom columns on your own and you may run into issues with various other plugins … Read more

Automatically fill custom field value on post publish/update

See add_meta_box which has a lot of demo code for working with meta fields. Here is the most relevant part for you: /* Do something with the data entered */ add_action( ‘save_post’, ‘myplugin_save_postdata’ ); /* When the post is saved, saves our custom data */ function myplugin_save_postdata( $post_id ) { // First we need to … Read more

Issue with wp_insert_post and post_content field error Could not update post in the database

Today, I was trying to insert an imported data into WordPress. I was using wp_insert_post to insert data, and it threw the following error: WP_Error Object ( [errors] => Array ( [db_update_error] => Array ( [0] => Could not update post in the database ) ) [error_data] => Array ( ) ) My friend said … Read more

Post/Page Publish/Update button not clickable once I make an edit

It appears to be a bug, but one that can be hacked around each time it happens with about 2 seconds of work. This wordpress forum thread: If you’re using Chrome, right-click on the greyed-out “Update” button and select “Inspect Element”. You will see something to the likes of: <input name=”save” type=”submit” class=”button button-primary button-large … Read more