首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在register_taxonomy中显示“元”数组

如何在register_taxonomy中显示“元”数组
EN

WordPress Development用户
提问于 2019-12-11 05:44:17
回答 1查看 56关注 0票数 0

如何使"META“字段对填入的内容进行"META:[]”?我正在使用以下代码:

代码语言:javascript
复制
register_taxonomy( 'job_listing_category', 'job_listing', [
            'labels' => [
                'name'              => _x( 'Categories', 'Category taxonomy labels', 'my-listing' ),
                'singular_name'     => _x( 'Category', 'Category taxonomy labels', 'my-listing' ),
                'menu_name'         => _x( 'Categories', 'Category taxonomy labels', 'my-listing' ),
                'search_items'      => _x( 'Search Categories', 'Category taxonomy labels', 'my-listing' ),
                'all_items'         => _x( 'All Categories', 'Category taxonomy labels', 'my-listing' ),
                'parent_item'       => _x( 'Parent Category', 'Category taxonomy labels', 'my-listing' ),
                'parent_item_colon' => _x( 'Parent Category:', 'Category taxonomy labels', 'my-listing' ),
                'edit_item'         => _x( 'Edit Category', 'Category taxonomy labels', 'my-listing' ),
                'update_item'       => _x( 'Update Category', 'Category taxonomy labels', 'my-listing' ),
                'add_new_item'      => _x( 'Add New Category', 'Category taxonomy labels', 'my-listing' ),
                'new_item_name'     => _x( 'New Category Name', 'Category taxonomy labels', 'my-listing' ),
            ],
            'rewrite' => [
                'slug' => $permalink_structure['category_base'],
                'with_front'   => false,
                'hierarchical' => false,
            ],
            'hierarchical'          => true,
            'update_count_callback' => '_update_post_term_count',
            'show_ui'               => true,
            'show_tagcloud'         => false,
            'public'                => true,
            'show_in_rest'          => true,
        ] );
EN

回答 1

WordPress Development用户

发布于 2019-12-11 09:28:26

您可以从json获得数组,如下所示:

代码语言:javascript
复制
$request = wp_remote_get( 'https://parquedasfeiras.online/wp-json/wp/v2/job_listing' );
if( is_wp_error( $request ) ) {
    return false; // Bail early
}
$body = wp_remote_retrieve_body( $request );
$data = json_decode( $body );
if( ! empty( $data ) ) {

    foreach($data  as $subdata){
        print_r($subdata->meta);
    }

}
票数 0
EN
页面原文内容由WordPress Development提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://wordpress.stackexchange.com/questions/354331

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档