I’m happy to announce my second ever self-created WordPress widget! Yay! This widget allows you to show off the number of books you’ve reviewed so far this year. I know most people have the Goodreads “Reading Challenge” widget — that’s great. I used it for a while but decided it was too bulky for my taste. I try to reduce the amount of images I have in my sidebar and I just didn’t like how big and inflexible it was. This widget is very unobtrusive and the output is made up purely of text and HTML! Plus, it updates completely automatically!
- Must be using a self-hosted WordPress blogging platform.
- Must be able to upload new plugin files.
- All book reviews must be in their own designated post category.
What We’ll Be Creating
As I explained before, this widget will output the number of books you have reviewed so far this year. It also gives you the option to set a goal for yourself. This widget is an alternative to the Goodreads reading challenge widget. It is ideal for people who want something unobtrusive and textual (no graphics to slow down page loading times!).
Here’s a brief overview of how it works:
On the admin-side of things, you will be prompted to enter in your own widget title, to be displayed in your sidebar. Leaving it blank is perfectly fine too. There is one required field you must fill out: the slug of your book review category. You can find this out by navigating to Posts » Categories, locating your book review category and copy/pasting text in the “Slug” column.
Another optional field you can fill out is your goal reviews. This is how many books you’d like to review that year. You may also enter in a link to your review page. If you enter a link in this box, then the widget will include a link to read all your reviews. You may also choose to check or uncheck a box that says “Display progress bar.”
In the backend, here’s how the plugin works. First we figure out what year it currently is. Then we do a query to find all posts in your book review category that were created in the current year. We figure out how many posts match those criteria and display them in the sidebar. If a goal number was entered, then it’s displayed as: Current/Goal (i.e. 10/50). The final output is:
“I have reviewed #/# books so far this year.
Where the # signs are the books you’ve reviewed, and your goal amount (if applicable). If you chose to display the progress bar, then a small progress bar will be displayed below that. And finally, if you entered in a link to your reviews, the text “Read Reviews »” will be displayed as a link.
Here’s what the widget would look like with all the options selected and filled out:
All the outputted elements are assigned classes, so if want to change the look and feel of the output, you may do so in your theme’s CSS file. For example, using CSS you could change the progress bar’s colours (as I have done in the example image above — the defaults are neutral grays).
First, you need to download this file. It is a .zip file with a .php file inside. The PHP file is what contains the widget code.
Then, in your WordPress admin panel, navigate to Plugins » Install Plugins. Simply select the .zip file that you downloaded and press Install Now.
After that (whichever method you chose), activate the plugin then you can go to your widgets page and add the widget to your sidebar! Simply fill out the options and you’re done!
If you have any questions about how to get this installed or if you run into any problems, just let me know in the comments and I’ll try my best to help you! Also if you have any ideas for new features or widgets, leave your suggestions here. 🙂