Need help getting post meta data for url
-
I’m using the code below to retrieve images from Instagram that have a certain hashtag. The problem is I’m trying to make it so
$tag_id
is pulled from the custom field in the post.I know it has to do something with this:
get_post_meta( $post->ID, 'tag_id', true);
I just cant get it to work.<?php function get_instagram($tag_id=marshmallow,$count=20,$width=100,$height=75 ){ $url = 'https://api.instagram.com/v1/tags/'.$tag_id.'/media/recent?client_id=10e03dd47cee4829a4aa8c93561a8ddb&access_token=37653788.10e03dd.d720972a6ef2422f974fb72127845370&count='.$count; // Cache the results as the instagram API is slow $cache = './'.sha1($url).'.json'; if(file_exists($cache) && filemtime($cache) > time() - 60*60){ // If a cache file exists, and it is newer than 1 hour, use it $jsonData = json_decode(file_get_contents($cache)); } else { $jsonData = json_decode((file_get_contents($url))); file_put_contents($cache,json_encode($jsonData)); } $result = '<div id="instagram">'.PHP_EOL; foreach ($jsonData->data as $key=>$value) { $result .= "\t".'<a class="fancybox" data-fancybox-group="gallery" title="'.htmlentities($value->caption->text).' '.htmlentities(date("F j, Y, g:i a", $value->caption->created_time)).'" style="padding:3px" href="'.$value->images->standard_resolution->url.'"> <img src="'.$value->images->low_resolution->url.'" alt="'.$value->caption->text.'" width="'.$width.'" height="'.$height.'" /> </a>'.PHP_EOL; } $result .= '</div>'.PHP_EOL; return $result; } echo get_instagram(); ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Need help getting post meta data for url’ is closed to new replies.