[ADD DATA API] Thêm dữ liệu vào post (ok)
Previous[AUTHENTICATE] Tạo oauth trong wordpress site [wordpress.org]Next[ADD DATA API] Thêm dữ liệu vào search (ok)
Last updated
Last updated
function post_featured_image_json( $data, $post, $context ) {
$data->data['featured_image_url'] = wp_get_attachment_url(get_post_thumbnail_id($post->ID),'full');
// $data->data['webbupointfinder_items_address'] = get_post_meta($post->ID);
$data->data['webbupointfinderitemsaddress'] = get_post_meta($post->ID,'webbupointfinder_items_address');
$data->data['webbupointfinderitemslocation'] = get_post_meta($post->ID,'webbupointfinder_items_location');
$data->data['webbupointfinderitemfieldtelephone'] = get_post_meta($post->ID,'webbupointfinder_item_field_telephone');
$data->data['webbupointfinderitemfieldmobile'] = get_post_meta($post->ID,'webbupointfinder_item_field_mobile');
$data->data['webbupointfinderitemfieldemail'] = get_post_meta($post->ID,'webbupointfinder_item_field_email');
$data->data['webbupointfinderitemfieldwebsite'] = get_post_meta($post->ID,'webbupointfinder_item_field_website');
$data->data['webbupointfinderitemcustommarker'] = get_post_meta($post->ID,'webbupointfinder_item_custom_marker');
$data->data['webbupointfinderitemheaderimage'] = get_post_meta($post->ID,'webbupointfinder_item_headerimage');
$data->data['webbupointfinderitemsliderimage'] = get_post_meta($post->ID,'webbupointfinder_item_sliderimage');
return $data;
}
add_filter( 'rest_prepare_post', 'post_featured_image_json', 10, 3 );