What action hook updates post meta?
wp_update_post isn’t used for updating custom fields (ie postmeta content) – you should use update_post_meta
wp_update_post isn’t used for updating custom fields (ie postmeta content) – you should use update_post_meta
From codex: $meta_value (mixed) (required) The value of the custom field you will add. An array will be serialized into a string. Default: None So <?php add_post_meta(7, ‘fruit’, ‘banana’, ‘apple’, ‘tornado’, ‘bob saget’) To grab them you can also use http://codex.wordpress.org/Function_Reference/get_post_custom_values besides just get_post_meta.
Nav menus are also generated by a WP_Query, so in your pre_get_posts callback function you need to check if the $query you’re altering is the main query. The easiest way to do this would probably be to do this right at the beginning of the function: if ( ! $query->is_main_query() ) return $query; Also note … Read more
How can I create a WP_Query that returns posts where one meta_value <= another meta_value
The context of your code that fails isn’t entirely clear, but it’s failing because get_the_ID() won’t return a post ID when run on the init hook, because the main query hasn’t been executed yet. If you have a look at the Action Reference, wp is the earliest action where you can access the current query’s … Read more
The function signature for update_post_meta() looks as follows: update_post_meta( int $post_id, string $meta_key, mixed $meta_value, mixed $prev_value=”” ) So instead of update_post_meta( $post ); you need to use update_post_meta( $post->ID, ‘my_post_meta_key’, $content_you_want_to_add ); I can only assume that you want to add this description to post meta. For that you’d use update_post_meta( $post->ID, ‘_my_post_description’, $entry[1] … Read more
You can add a new bulk action for posts with this code : $postType = “post”; add_filter(“bulk_actions-edit-” . $postType, function ($actions) { $actions[“specialSave”] = “Special save”; return $actions; }, 20); add_filter(“handle_bulk_actions-edit-” . $postType, function ($sendback, $doaction, $post_ids) { if (“specialSave” !== $doaction) { return; } foreach ($post_ids as $idPost) { // action to do for … Read more
I think your approach is not the good one. If I understand well, What you want to do is keeping the old permalinks for the old posts and stick with them, while having the new permalinks only for the new posts. You should consider having the new permalink structure for all the posts (old and … Read more
It’s unclear what the postmeta actually does so it could effect your website in any number of ways.At best it will just clear the field / option and the user will need to re-enter it for that specific page.At worst it could change a pages layout or orphan a media file in your media library … Read more
Finally got a solution. I was not able to get meta key ie my_key value then I used: $post_id = get_the_ID(); $has_customization = get_post_meta($post_id, ‘my_key’, true);