Title: YouTube API Decoded JSON Data in Loop?
Last modified: August 20, 2016

---

# YouTube API Decoded JSON Data in Loop?

 *  [SlightlyAmiss](https://wordpress.org/support/users/slightlyamiss/)
 * (@slightlyamiss)
 * [13 years, 8 months ago](https://wordpress.org/support/topic/youtube-api-decoded-json-data-in-loop/)
 * Hello,
 * I am having a very difficult time echoing out JSON data within a loop. I have
   assigned a custom-field to each post which contains a YouTube video ID (key ytid).
 * Here’s what I currently have in the loop:
 *     ```
       <?php
           $videoID = get_post_meta($post->ID, 'ytid', true);
       	$query_url = 'http://gdata.youtube.com/feeds/api/videos/' . $videoID . '?v=2&alt=jsonc';
       	$json = json_decode($query_url);
       	$views = $json->data->views;
       	echo $views;
       	?>
       ```
   
 * This echoes back nothing. I’d like to ideally be able to pull additional info
   from the JSON file as well, such as comment count, like count, etc. Is my syntax
   incorrect? Any help would be greatly appreciated!

The topic ‘YouTube API Decoded JSON Data in Loop?’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [SlightlyAmiss](https://wordpress.org/support/users/slightlyamiss/)
 * Last activity: [13 years, 8 months ago](https://wordpress.org/support/topic/youtube-api-decoded-json-data-in-loop/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
