Hot answers tagged

1

Try this, with " tags on .= '<a href="'.get_permalink($id).'"><img src="'.$image['url'].'" /></a>';


1

WP API has a rest_prepare_post filter (or rest_prepare_CPT if you are working with custom posts) which you can use to modify the JSON response. In your case it will be rest_prepare_joblisting. function filter_joblisting_json( $data, $post, $context ) { $phone = get_post_meta( $post->ID, '_phone', true ); if( $phone ) { $data->data['phone'] = ...


1

$post in the callback function is an array, not an object. So you cannot use $post->id. Change it to $post['id'] and it should work: function slug_get_phone_number($post, $field_name, $request) { return get_post_meta($post['id'], '_phone', true); } I recommend to change _phone to phone_number or something else without underscore prefix. Because _ ...



Only top voted, non community-wiki answers of a minimum length are eligible