add_action('init', function () { $rank_math_meta_fields = [ 'rank_math_focus_keyword', 'rank_math_title', 'rank_math_description', ]; foreach ($rank_math_meta_fields as $meta_key) { register_post_meta('post', $meta_key, [ 'show_in_rest' => true, 'single' => true, 'type' => 'string', 'auth_callback' => function ($allowed, $meta_key, $object_id) { return current_user_can('edit_post', $object_id); }, ]); } });