get_field not works inside foreach loop
-
I m Begginer at php and try to get advance custom field
It shows Gallery images of post by post id
it works on web page but not at web service file
it is not plugin or web page and works to return Rest API as Web Serviceforeach ($mylink as $prj){ $galleries = Array(); $pid = $prj->id; $gs = get_field('gallery' , $pid); if($gs == null){ $gs = Array(); } foreach ($gs as $g){ $c = new stdclass(); $c -> id = $g["ID"]; $c -> url = $g["url"]; $galleries [] = $c; } $prj -> PID = $pid; $prj -> GS = $gs; $prj -> gallery = $galleries; } wp_reset_query(); $results_array['msg'] = 'Success'; $results_array['status'] = true; $results_array['result'] = $mylink; $results_array['current_time'] = date("Y-m-d H:i:s"); echo $ws->unicodeString(json_encode(array('posts'=>( $results_array ))), 'UTF-8');
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘get_field not works inside foreach loop’ is closed to new replies.