Use last.fm to play music in your sidebar
By creating a library of your favourite artists at last.fm you can share your music with your blog readers.
There are several MP3 player plugins available, but by using last.fm’s player you will be completely legal and will avoid using loads of your bandwidth by streaming the tracks yourself!
You can choose from a few different colours - so it will match your site - along with other display options. Whenever you add more artists to your last.fm library they will be instantly available on your blog’s playlist.
1. Sign up to last.fm and add artists to your library
Sign up to last.fm if you aren’t already a member. You can search for your favourite artists and add them to your library using the blue button show in the screenshot below. You can add artists at any time without needing to modify your widget, so just add a few for now to get you started.

2. Create a player widget on last.fm
Once you’ve added some artists go to www.last.fm/widgets to create a player widget. On my own site I’m using a “radio player” to play random tracks chosen from my entire library. “Quilts” shows ever-changing images of album covers from yoru library, which looks fun! The other option available to WordPress users is “charts”: this will only play tracks you have recently played on last.fm.
You can also select the colour and size of your widget. When you’re happy with it press “Show me the code” and copy the code it gives you onto the clipboard, ready to add it to WordPress.
The final step will vary depending on whether or not your theme uses WordPress widgets. If your theme supports widgets you can do step 3a. If your theme doesn’t support widgets, or if you choose not to use them, do step 3b. Note that as soon as you add a single widget in Design > Widgets it will replace your whole default sidebar in most themes, so you will need to add other widgets alongside your new widget.
3a. Using the widget if your theme is widget-enabled
If your theme supports widgets, and you choose to use them, adding the last.fm player is easy. Go to Design > Widgets in WordPress Site Admin. At or near the bottom of the unused widgets on the left you will see you can add a “Text” widget. After pressing “Add” it will appear on the list on the right. Press “Edit” on this new widget.
There is space for an optional title at the top and a space for you to paste in the code from step 2.
Once you’ve done that, press “Change” to save the text widget, then “Save changes” to make your new widget appear on your site. Take a look at your site, press play and turn up the volume!

3b. Using the widget if your theme doesn’t use WordPress widgets
If your theme doesn’t use widgets, or if you just prefer not to use them, you’ll need to edit your theme’s sidebar template. You can find this at wp-content/themes/your-theme-name/sidebar.php. If you want a guide to editing theme files read Making a theme series (part 1). I’m going to add my last.fm player under the tag cloud, but you can add it wherever you like. Find the place you want to put it and paste in the code from step 2. Lines 11 and 12 below represent the pasted code, but I haven’t included it all here because it’s huge!
<div id="sidebar">
<ul id="navigation">
<li><a href="<?php bloginfo('url'); ?>" Title="Home">Home<a></li>
<li><a href="<?php bloginfo('url'); ?>/tag/photos" Title="Gallery">Gallery<a></li>
<?php wp_list_pages('depth=1&title_li='); ?>
</ul>
<div class="wp-tag-cloud">
<h2>Tag cloud</h2>
<?php wp_tag_cloud('smallest=0.8&largest=1.8&unit=em'); ?>
</div>
<style type="text/css"> (huge block of code from last.fm goes here)
<table (another huge block of code from last.fm goes here)
</div>
Upload your changed sidebar.php if you need to, then take a look at your site. You and your visitors can now enjoy music from your favourite artists!











I prefer to use a playlist from Favtape.
Hello…i’m using the Jentri theme for my wordpress blog. Apparently,when i copy the code into the text widget,the whole code itself is shown on the blog.I’m pretty sure i’m following the right procedure.Is there any solution to this ? i read somewhere that wordpress.com doesn’t support third party applications. please help.
I’m afraid that’s right, the text widget is only for plain writing, not code. I can’t think how you can put the player in your sidebar on WordPress.com. However you could try putting it on a page. Make a new static page, perhaps called “Music”. Edit that page and click HTML View. Try pasting the player code in there.
No…even that didn’t help.When i paste in html,again the whole code shows ! Anyways,thanks a lot for helping. I’ll put a rss link instead.
Above the text-entry box, where it says “Visual” and “HTML” did you make sure you pressed “HTML”?
This just isn’t working. Where is this “Visual” or “HTML” option? It’s not showing up on my dashboard.
I just tried putting Last.fm on my WordPress.com blog, and found that it won’t work. WordPress.com doesn’t support JavaScript. You’ll need a self-hosted WordPress to use this tutorial! Sorry, it hadn’t occured to me before.
Any idea how you can stop the player reloading whilst moving from post to post?
The only simple way I can think is using an IFrame in your sidebar. Link the IFrame to
lastfm.htmlor something like that, then put the Last.fm player code in that file.Thanks, worked for me! I’m on my own hosting, though.
No worries!
When I’m trying to access http://www.last.fm/widgets - it turns automatically to http://www.last.fm/tools/charts - and can’t create my own player. Can anybody help me with that? Thank you!
Leave your response!
What is WordPress?
Twitter
-
Issue 4 will be out some time in January. WP Mag is on holiday while its writer is busy after moving house!
-
WordPress Mag's holiday is going to be an extra week, so back on the first Wednesday in December
-
@MothersWork hi :) go to http://search.twitter.com and search for people talking about things you're interesting in :)
-
WordPress Magazine is taking two weeks off while I move house! I hope you don't miss new articles too much :P
-
@andreamercado oo, thanks! Bit phased out right now, will have a look when I feel like a read!!
-
Today's WordPress tip: reorder your category list in the sidebar http://zi.ma/1c3857
See @wpmag on Twitter03:10:46 AM December 06, 2008
08:50:34 AM November 15, 2008
05:11:45 PM November 13, 2008
12:38:51 PM November 11, 2008
11:01:25 AM November 10, 2008
10:57:39 AM November 10, 2008
Tags
categories colour CSS design Featured themes Grid Runner Adventures header Interviews last.fm Make a theme series music pages Plugins Private Plus register Register Plus search sidebar tags The Loop theme themes travel water widget WordPress.comMost Emailed
Most Commented
Most Viewed