Posts Tagged ‘PHP

Open wp-includes/functions.php file and add: function custom_field_get_post_meta_cb($object, $field_name, $request){ // return get_post_custom(); $metas = get_post_custom($post_id); foreach($metas as $key => $value) { if(sizeof($value) == 1) { $metas[$key] = $value[0]; } } return $metas; } function custom_field_update_post_meta_cb($value, $object, $field_name){ return update_post_meta($object[‘id’], $field_name, $value); } add_action(‘rest_api_init’, function(){ register_rest_field(‘post’, ‘custom_fields’, array(‘get_callback’ => ‘custom_field_get_post_meta_cb’)); });

Eğer yukarıdaki hatayı alıyorsanız son çalıştığınız dosyayı / dosyaları notepad++ ta açıp format menüsünden “Encode in UTF-8 without BOM” seçerek kaydedin. Sonuca şaşırıp PHP yi bir kez daha seveceksiniz 😛

Microsoft yine hayatı kolaylaştırıcı bir tool sunuyor. Web ortamı için gerekli bütün toolları bir kaç tıkla kurmanızı sağlayacak (klasik ASP ve PHP dahil) bir sihirbaz. Daha fazlası için


top