问题描述
我正在尝试从自定义帖子类型 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 (将#修改为@)