What is a widget anyway? Well, the simple explanation is that it’s a mini-app of sorts. You can use it to do something as simple as run a line of HTML code that displays a follow button in the sidebar of your WordPress blog or it can be a companion piece to a plugin. There are also several widgets that are part of the standard WordPress installation like a calendar, tag cloud and a search button. If you’re looking for a simple way to add functionality to your WordPress website, you may need to look no further than the simple text widget.
Text Widgets and YouTube
One of my clients has two distinct target markets. Her primary market is businesses that can benefit from her product and her secondary market is entrepreneurs who want to join her multi-level-marketing program. She wanted one website that would meet the needs of both niche target markets. We accomplished this partly by having separate pages for businesses and entrepreneurs.
This client has her own YouTube channel (with videos that she personally created) and she also has access to videos created by the company that she markets for. We wanted to showcase different videos in the sidebars of specific pages. To accomplish this, I followed these simple steps:
Embedding a YouTube Video into a WordPress Sidebar
#1) Locate the video that you want to include and click on the share button.
#2) Click on the embed button.
#3) Copy and paste the code that appears. (Note: Set the width before you copy the code and the height will set proportionately.)
#4) Go into your WordPress Admin panel under Appearance, Widgets and drag a text widget into the sidebar where you want it to appear. You can either enter a title or leave it blank. Then, simply paste the code that you copied in step #3 into the box. Click on the save button and you should be done.
Controlling the Page that A Widget Appears On
As I mentioned earlier, I did not want each video to appear in the sidebar for every page. The solution that I used was to install the widget-logic plugin. (I installed and activated it prior to creating the text widget.) As you can see in the screenshot below, I have entered a simple line of code is_page ( array( ‘business-uses’, ‘the-company’ ) ) in the “Widget Logic” box. In this instance the embedded YouTube video will display on two pages, business-uses and the-company. Widget Logic code can be a little tricky to learn but there are lot of tutorials and once you get the hang of it, you’ll be coding it in no time.
Widgetize Your WordPress Website
Widgets don’t need to be confined to the sidebar area of your website. For those of you who aren’t afraid of modifying your functions.php file and want to modify your WordPress template to incorporate a widget, check out How to Widgetize Your WordPress Theme in 2 Steps by Jeff Starr. For those of you who don’t know, Chris Coyier and Jeff Starr are the authors of the book Digging Into WordPress (which I highly recommend reading). This book was instrumental in my learning WordPress when I first started blogging and it continues to be a resource for me. (Its available as both a PDF/eBook and in print. Both versions include free lifetime updates of all future versions.)
Now, it’s your turn. What do you use text widgets for? Do you have any tips that you can share with the rest of us? Are there any other fans of Digging Into WordPress or do you have another favorite resource for mastering WordPress? As always, we’d love to hear from you.