Save post in another table

The original post_date is saved post_date and post_date_gmt. And modification dates are saved on post_modified_date and post_modified_date_gmt. So you never lose your original creation date.

Changing new post to “pending” on publish – but “Publish failed” – why?

The wp_update_post hook will call the same action twice, as the action save_post_{$post->post_type} is called in this function. I would add remove_action( ‘save_post_tribe_events’, ‘set_to_pending’); before wp_update_post( $post ); and add_action( ‘save_post_tribe_events’, ‘set_to_pending’, 10, 3 ); after it works 🙂 function set_to_pending($id, $post, $update){ $the_post = print_r($post, true); $the_post_author = $post->post_author; $the_post_url = get_edit_post_link($id); $the_post_url = … Read more

Update current WP post every 3 minutes [closed]

Classic Editor: autosave.js file setInterval(function () {document.getElementById(“publish”).click()}, 300000); php function // Load js file on specific post type in class editor function load_js_file_classic_editor( $hook ) { global $post; if ( $hook == ‘post-new.php’ || $hook == ‘post.php’ ) { if ( ‘post’ === $post->post_type ) { wp_enqueue_script( ‘myautosave’, get_stylesheet_directory_uri().’/includes/js/autosave.js’ ); } } } add_action( ‘admin_enqueue_scripts’, … Read more

where does this $post_id come from?

It comes from wp_insert_post(), where do_action() is called with two additional parameters: do_action(‘save_post’, $post_ID, $post); So it is not you who adds the parameters, it is WordPress. If you register your callback with the fourth parameter set to 2 … add_action( ‘save_post’, ‘mytestfunc’, 10, 2 ); … you will even get the complete $post object: … Read more

Cant’t delete my custom posts

Of course your custom posts can’t be trashed. They can’t even get set to private or draft or anything else then publish because your callback change_content() always sets the post status to publish every time a post (of your custom post type) gets saved. However trashing a post just means setting its status to trash. … Read more

Using PODS data with save_post

Yes, whenever a post is saved you should see all of the input items in $_POST … if you’re not using something like xdebug to debug with, you could do something like: echo “<pre>”; var_dump( $_POST ); echo “</pre>”; To test and see what is all included in $_POST … note this is just for … Read more

Reset all transients on post or page save

The technical side of it depends on the storage used. For default database storage the transient entries can be queried and deleted, since they have specific naming format. For enabled Object Cache storage cache can be flushed, which will get got cache and transient. The practical side of it — this is Bad Idea. Transients … Read more

Compare custom taxonomies of updated post (or new post) [Updated with progress]

Use the set_object_terms hook, http://adambrown.info/p/wp_hooks/hook/set_object_terms?version=3.4&file=wp-includes/taxonomy.php It should be fired when a post or page is modified. Here is the code that fires it: do_action(‘set_object_terms’, $object_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids); You can thus check against the $object_id and taxonomy, and flush your transient cache and regenerate as needed. Specifically, clear the term caches of the … Read more