So you’ve got your well designed blog button and you’re ready to add it to your sidebar. Rather than making your readers “Save As” and create their own links to your blog, you can give them the code straight from your sidebar or post.
Not only does this make your button infinitely easier for a reader to add to their blog, it also gives you control over SEO information like the Alt text and image title – both of which are used by Google to send more readers your way.
The Code
The HTML code for this isn’t too complex. First, you’ll be entering the code to display the image itself. Note that when you’re creating a link for use on other websites, it’s good practice to go ahead and enter the Alternate text (the text that pops up when you hover over an image) and the image title – it’s good practice for your Search Engine Optimization (SEO). That’s the extra information you see in the code below.
The second half of the equation is creating the box with the grabbable link text inside:
To add both elements at the same time, I wrap them in a <div> tag to group them together, and I usually want them to appear centered in my sidebar or in my post, so I’ll align them inside the <div> tag. The whole thing, together, looks like this:
Using WordPress to add a Button with Grab Code
In WordPress, you’ll start by uploading your image into your Media Library, taking note of the Image Location. You may want to copy and paste this URL into Notepad.

Then, depending on the location where you want your button to appear, you’ll use either a Text Widget or open up the HTML editor for your post. I’ll show you how to do both of these.
Adding your button with grabbable code in the sidebar:
To add this button into your sidebar, you’ll go to Appearance > Widgets and add a text widget to whichever widget area you want it in. Then paste the code (above) into your text widget, replacing the variables I indicated (in CAPS) with what corresponds to your image and link. Hit “Save” at the bottom of the widget and go preview your pretty new button!
Adding your button with grabbable code inside a post:
Adding these grabbable buttons inside a post is a little trickier, and it’s because WordPress doesn’t display them well in the Visual editor. Before you add your button, make sure you’ve finished the rest of your post and have it looking exactly like you want it. Then switch over to the HTML view and find the right spot for it in your post. Copy and paste the code (above) into the post, replacing the variables (written in CAPS) with your correct information.
Once you have added the button code, DO NOT return to your visual editor. WordPress will mess it up and you’ll have to switch back to the HTML editor and do it over again.
Once you save the draft of this post, go preview it and make sure it looks right before you hit Publish.
Easy, right?
If you have trouble with any of these steps, please give me a shout out in the comments below. Now, go share your buttons!













Twitter: afterlaundry
says:
You just saved me! I was co-hosting a blog hop for the first time and couldn’t figure out why the button and text box kept messing up. I spent way to long switching around the code and finally read your post about not switching back to visual mode. Thank you! Thank you!
Twitter: theblogmaven
says:
Glad it worked out for you, Brenna. I hope that’s something WordPress gets figured out in the coming versions…but for now, the HTML editor is the safe place to be.
Twitter: JenCarrollVA
says:
Hi Jeni! Thank you so much for this helpful post! I got it to work but have one little problem. On my website when I click on the button code to highlight it, that little screen goes blank… strange. Any ideas why that might be happening?
Twitter: theblogmaven
says:
Hi Jennifer, I just went over to your site and…I’m completely stumped. It’s like the browser is reading that CSS as an input area, rather than a readonly textarea. I checked your HTML and it’s all in there fine. I’m wondering if it’s a CSS issue in your theme? Anyway – very frustrating. I’m sorry to not be of more help. :/