add_action('init', function () { foreach (get_post_types(['public' => true]) as $type) { foreach (['_yoast_wpseo_metadesc', '_yoast_wpseo_meta-robots-noindex'] as $meta) { register_post_meta($type, $meta, [ 'show_in_rest' => true, 'single' => true, 'type' => 'string', 'auth_callback' => function () { return current_user_can('edit_posts'); }, ]); } } });