Blah, blah, blah.

What's all the hub bub, bub?

What Do We Have To Say?

Apr
29
2009

WordPress How-To: Display Category Name Based on Slug

I’ve been developing sites on WordPress for awhile now, and I love it for a number of reasons. It’s fully customizable, has an incredibly intuitive and easy-to-use interface, and the thousands of plugins available pretty much cover all the bases for any functionality you could possibly need.

I’ve also been learning lots of nice little tricks for customizing themes. I plan to occasionally post little tutorials describing some of these tricks. Hopefully, someone will find some use for them, and save themselves a little time!

One trick that I just used and that took forever to find is the ability to display the current category name somewhere on the page. Specifically, I wanted to be able to output this in an <h1> tag on my category.php page. I tried a plugin that was supposed to provide additional template tags that aren’t included in a native WordPress installation. That didn’t work; it kept outputting the default category. I tried lots of thing, and finally found the solution I was after.

<?php single_cat_title(''); ?>

Pretty simple, right? This will simply display the category name on the page based on the category slug on the current page. If you want to add some text to display before the category name, you would use:

<?php single_cat_title('You are reading about '); ?>

Which, if the current category was WordPress, would look like this:

You are reading about WordPress

Alternately, you can assign the category name to a variable for use in your code. That would look something like this:

$current_category = single_cat_title("", false);

Pretty cool, huh?

Apr
09
2009

P.B. Loco Peanut Butter

I’m pretty much a food freak, I love food, love eating, love watching about it, love the smells that come out of the kitchen, lol! Just love love love food! One of my favorites is peanut butter, can’t get enough of the stuff. Thought I’d share this cool brand of peanut butter I came across, called P.B. Loco. On top of your regular smooth and creamy, and chunky choices of peanut butter, P.B. Loco also offers some unique and sophisticated flavors, such as Asian Curry Spice and Raspberry White Chocolate. You can get some at their online shop or if you are fortunate enough to have a P.B. Loco Cafe nearby, you should stop by there and pick up a jar or two! At their cafes, you can do some sampling, as well as order a variet of peanut butter sandwiches! They’ve got some fun and crazy things going on, definitely make a point to check it out. Check out this lens I wrote about it on Squidoo!

Loco for Peanut Butter