Resaving posts to update static blocks
Resaving posts to update static blocks
Resaving posts to update static blocks
A very easy way to accomplish this would be to add something like this into your themes functions.php file: function update_post(int $id, \WP_Post $post, bool $update) { // Case the post object to an array $data = (array) $post; // Set the title to the ID of the post $data[‘post_title’] = $id; // We need … Read more
Detect, if post is saved manually or programmatically in save_post-hook
After some research, I altered my approach to validate the meta values in the following way: Create a new meta key(for post type) to store the validation (0 and 1). Initiate it with 0. This need not be kept/shown in the meta form. While saving the meta fields (preferably within save_post hook), set its value … Read more
Multiple triggers when publishing, saving or updating a post in WordPress
A way to see real changes of posts inside an action?
The answer is don’t use wp_set_post_terms, use wp_set_object_terms instead. wp_set_post_terms only works with the built-in post object.
Your code calls get_the_category() but it doesn’t use the value returned. // … if ( isset( $_POST[‘img-destacada’] ) ) { $categories = get_the_category($post_id); $img = ”; // $categories should contain either an array of WP_Term objects, // or an empty array. if ( ! empty( $categories ) ) { // Here I’ve used the slug … Read more
How to use wp_set_object_terms depending on page ID?
Use save_post to generate file on wordpress