How to Get Instagram Photos by Tag and of any User without Access Token

And now let me disappoint you, just for a little – WordPress only. πŸ‘

The code below is a wrapper of my hardcoded functions, that are interacting with WordPress HTTP API and process the result.

No more words, let’s code.

By a Tag. No Access Token required

You can use the below code just in a place where you would like to display photos.

$instagram = new mishaInstagram();

$by_tag = $instagram->serve_tag_media( 'dombay', 30 ); // 30 is how much photos you would like to display

// your can just prin_r() the result to view all the parameters
// print_r( $by_tag );

if( !is_wp_error( $by_tag ) ) {
	$html = '
    '; foreach ( $by_tag['response'] as $photo ) { $html .= '
  • '; // instagram link $html .= ''; // hi-res photo: $photo['display_url'] $html .= '
  • '; // $photo['taken_at_timestamp'] – publish date // $photo['dimensions']['height'] and $photo['dimensions']['width'] – original height and width // $photo['edge_media_to_caption']['edges'][0]['node']['text'] – caption :D // $photo['edge_liked_by']['count'] – number of likes // $photo['edge_media_to_comment']['count'] – number of comments // print_r( $photo ) – for more parameters } $html .= '
'; echo $html; }

But what is mishaInstagram()? This class makes all the nasty job – it is the part of my plugin you have to install first to make this code work.

Photos from any user. No Access Token again

This code is very similar to the previous one where we get photos by a tag.

$instagram = new mishaInstagram();

$user_photos = $instagram->serve_user( 'rudrastyh', 10 );
print_r( $user_photos['media'] );

How to find out an Instagram user ID?

Earlier you could get Instagram user ID from html code on his profile page. It is not possible anymore. But the below code will help you:

$instagram = new mishaInstagram();

$user = $instagram->serve_user( 'rudrastyh' ); // get user info as an array
echo $user['profile']['pk']; // profile ID

P.S. I forgot when last time I published a tutorial to promote my plugins, half-year ago or so. But my website doesn’t have any ads πŸ˜‹ and the next tutorial is going to be awesome πŸ”₯

Misha Rudrastyh

Misha Rudrastyh

Hey guys and welcome to my website. For more than 10 years I've been doing my best to share with you some superb WordPress guides and tips for free.

Need some developer help? Contact me

Follow me on X