Coders Packet

WordPress Plugin to Add a Spotify Link to Any Song or Artist

By Smitha S Maganti

This WordPress plugin allows the user to customize the name of the artist or song, and add a Spotify link to the same on their webpage easily. It is written in PHP.

Steps to upload and customize the plugin: 

The name of this WordPress plugin is "spotify artist or song link plugin". The steps to upload and use this plugin are explained with an example of a  sample website built using WordPress. 

1) Download the plugin's zip file, and upload the same on your WordPress site:

The first step is to download the plugin and upload it on WordPress. To upload the plugin on your WordPress dashboard, go to, Plugins -> Add New -> Upload Plugin. The plugin has to be uploaded as a zip file with the same name as the plugin.

Once the plugin is uploaded, activate the plugin if it is not activated. To do this, go to, Plugins -> Installed Plugins -> Go to the required plugin and click on activate.  

Example of how the plugin looks once uploaded and activated

  Fig 1. Example of how the plugin looks once uploaded and activated. 

2) Customize the plugin by adding the name of the song or band: 

Once the plugin is activated, the next step is to customize it. After the plugin is added, a new sub-section called Spotify will appear on the customize section on your WordPress dashboard. To navigate to the customize section, go to, Dashboard -> Appearance -> Customize.  

Customizing the plugin

Fig 2. Spotify is added to the customize section.

The next step is to click on the Spotify sub-section, enter the name of the artist or song in the text box provided, and publish the changes made.
Note: If the song or band name is not mentioned and the text box is empty, the link will not appear on the webpage. 

Adding the name of the song or artist

Fig 3. Entering the name of the band or song, in this example One Direction.

3) Add the shortcode to display the link on the webpage:

After customizing the plugin, add the shortcode "[listen] Title [/listen]" to display the required link of the artist mentioned on your webpage. 

The title can be anything you want. If no title is mentioned, the default title which says "Click here" will appear on the webpage. They are multiple ways to add the shortcode. 

One way is by going to dashboard -> Posts -> All Posts. Here edit the post you want to add the link in, place the shortcode mentioned above in the position you want and update the changes.

Adding the shortcode to display the required link

Fig 4. Add the shortcode. In this example, the title given to the link is "click here to navigate to the band/song on Spotify". 

After uploading and customizing the plugin:

Once the shortcode is in place, the link to the customized song/artist will be displayed on the webpage with the specified title as shown below. 

Webpage after adding the shortcode

Fig 5. Displaying the link with the title mentioned. 

When the link is clicked, the webpage navigates to the respective Spotify page of the artist or the song as shown below. The link leads to the search result page of the specified artist/song on Spotify. This can be changed according to your needs in the source code of the plugin. 

Spotify page

  Fig 6. Spotify page of the artist One Direction. 

Download Complete Code

Comments

No comments yet