微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

WP API 响应不显示我注册的元数据

如何解决WP API 响应不显示我注册的元数据

我正在尝试从自定义帖子类型 splash_location 获取元数据,但是它没有出现在我的回复中。我已经注册了我的元标记 splash_location_title,但它没有出现在我的 JSON 请求中。

function splash_location_custom_post_type() {
  register_post_type('splash_location',array(
      'labels'      => array(
        'name'          => __('Locations','textdomain'),'singular_name' => __('Location',),'supports' => array( 'title','custom-fields' ),'menu_icon'   => 'dashicons-admin-page','public'      => true,'has_archive' => true,'show_in_rest' => true,)
  );
}
add_action('init','splash_location_custom_post_type');

$Meta_args = array( 
    'type'         => 'string','description'  => 'A Meta key associated with a string Meta value.','single'       => true,);
register_Meta( 'splash_location','splash_location_title',$Meta_args );



//Code in my block file to get splash_location data   
const getLocationPosts = () => axios
    .get('/wp-json/wp/v2/splash_location/')
    .then(response => {
        const { data } = response
        console.log(data)
    })

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。