Title: WordPress plugin with last.fm API
Last modified: August 19, 2016

---

# WordPress plugin with last.fm API

 *  Resolved [jocken](https://wordpress.org/support/users/jocken/)
 * (@jocken)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/wordpress-plugin-with-lastfm-api/)
 * Trying to make a last.fm plugin for wordpress, it’s for a school project so I
   can’t use the existing ones + they don’t do what I want.
 * I just want to display images of artists, nothing else. However, I have problems
   with getting the hyperlink to work properly (trying to get the post title as 
   artist name). Is it necessary to have great knowledge in object oriented php 
   to make this work?

Viewing 1 replies (of 1 total)

 *  Thread Starter [jocken](https://wordpress.org/support/users/jocken/)
 * (@jocken)
 * [15 years, 9 months ago](https://wordpress.org/support/topic/wordpress-plugin-with-lastfm-api/#post-1672550)
 * Okay, I’m almost done, but I get 5 images instead of 1.
 * This is the foreach loop
 *     ```
       foreach($xml->children() as $first){
       			foreach ($first->children() as $second){
       				foreach ($second->children() as $third){
       					foreach ($third->size as $fourth){
       						echo $fourth->getName() . ' <img src="' . $fourth . '" /><br />';
       					}
       				}
       			}
       		}
       ```
   
 * And this is the xml
 *     ```
       <sizes>
                           <size name="original" width="380" height="498">http://userserve-ak.last.fm/serve/_/28239435/Attack+Attack.png</size>
                           <size name="large" width="126" height="165">http://userserve-ak.last.fm/serve/126/28239435.png</size>
                           <size name="largesquare" width="126" height="126">http://userserve-ak.last.fm/serve/126s/28239435.png</size>
                           <size name="medium" width="64" height="84">http://userserve-ak.last.fm/serve/64/28239435.png</size>
                           <size name="small" width="34" height="45">http://userserve-ak.last.fm/serve/34/28239435.png</size>
                           <size name="extralarge" width="252" height="330">http://userserve-ak.last.fm/serve/252/28239435.png</size>
                       </sizes>
       ```
   
 * And it prints out this:
 *     ```
       <img src="http://userserve-ak.last.fm/serve/_/28239435/Attack+Attack.png" /><br />
       size <img src="http://userserve-ak.last.fm/serve/126/28239435.png" /><br />
       size <img src="http://userserve-ak.last.fm/serve/126s/28239435.png" /><br />
       size <img src="http://userserve-ak.last.fm/serve/64/28239435.png" /><br />size <img src="http://userserve-ak.last.fm/serve/34/28239435.png" /><br />
       size <img src="http://userserve-ak.last.fm/serve/252/28239435.png" /><br />
       size <img src="http://userserve-ak.last.fm/serve/_/47506887/Attack+Attack+crabcrabcore.jpg" /><br />size <img src="http://userserve-ak.last.fm/serve/126/47506887.jpg" /><br />
       size <img src="http://userserve-ak.last.fm/serve/126s/47506887.jpg" /><br />size <img src="http://userserve-ak.last.fm/serve/64/47506887.jpg" /><br />
       size <img src="http://userserve-ak.last.fm/serve/34/47506887.jpg" /><br />size <img src="http://userserve-ak.last.fm/serve/252/47506887.jpg" /><br />
       size <img src="http://userserve-ak.last.fm/serve/_/47342891/Attack+Attack+attack.jpg" /><br />
       size <img src="http://userserve-ak.last.fm/serve/126/47342891.jpg" /><br />
       size <img src="http://userserve-ak.last.fm/serve/126s/47342891.jpg" /><br /> etc...
       ```
   
 * I get all 5 images, how do I only get the first?

Viewing 1 replies (of 1 total)

The topic ‘WordPress plugin with last.fm API’ is closed to new replies.

 * 1 reply
 * 1 participant
 * Last reply from: [jocken](https://wordpress.org/support/users/jocken/)
 * Last activity: [15 years, 9 months ago](https://wordpress.org/support/topic/wordpress-plugin-with-lastfm-api/#post-1672550)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
