Home > OS >  What action hook would I use to update post meta when viewing a post in Wordpress admin?
What action hook would I use to update post meta when viewing a post in Wordpress admin?

Time:11-22

Example URL: mywebsite.com/wp-admin/post.php?post=1234&action=edit

I have found hooks that fire when a post is created/edited/status changed, but nothing that works for just viewing a post.

I need to check some meta data and update it before the post is displayed to the user

I have tried several hooks already but none let me edit post meta at the correct time (when viewing a post)

CodePudding user response:

save_post hook in your case what you are trying to do show your code

CodePudding user response:

Not sure if there's a hook so you could either add one manually or use something like this

global $pagenow;
if (is_admin() && $pagenow == 'post.php') {

    // editing a post

}
  • Related