Get post id in a function when edit/add a post
Your function get_postid() does not return anything. It should return the id: function get_postid() { global $post; return $post->ID; } If you are going to use the $post_id I guess your first if statement is wrong, because the $post_id should be evaluated to true not false. So it should be like this: if ( $post_id … Read more