0

How do I get the "META" field to go off "META: []" for something filled in? I am using this code:

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,
        ] );
2
  • I don't understand the question. What meta field? Dec 11, 2019 at 6:07
  • Sorry for this, 'META' in JSON link. EXAMPLE You can see "meta: [ ]" Dec 11, 2019 at 6:08

1 Answer 1

0

You could get array from json like below:

$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);
    }

}
2
  • Hi! Thanks so much for where can I put this code? Dec 11, 2019 at 10:11
  • where you want to display the code i have put it in functions.php file Dec 11, 2019 at 10:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.