Unique Gadget Category With Sticky

13 April 2006

Well tonight I wanted to write about a little project I was working on tonight that I put together through the use of two plugins. This is just a testament of how great WordPress is and the community that encompasses it. Well let me tell you what I was aiming to achieve.

Before I switched my site over to WordPress, I hand coded everything, so I had a lot of room to do anything I wanted. I had a section on my site called ‘Gadgets’, where I posted all the toys I own. Well I’ve always wanted to add that back somehow, and tonight I aimed to do that. Here are a few things I wanted to acheive:

  • Part I   -  Have it’s own unique category, not showing posts on main page.
  • Part II  -  Have a sticky on that describes the category at the top.
  • Part III -  Have a link to the Gadgets category in my navbar.

Part I

So the first part was easy, creating a category called Gadgets. But I didn’t want the posts in the Gadget category to be displayed with all my other posts. I knew about this plugin in the past, but I used one called ‘Front Page Categories’ by Ryan Boren.

Link: http://dev.wp-plugins.org/file/front-page-cats/trunk/front_page_cats.php

To get this plugin to work, all you have to do is copy and paste that code, save it to a PHP file, and upload it to your plugin directory. Each WordPress category has a category ID number. So in my example, I had 8 categories, and the Gadget category is number 9. So I modified the code to say:

$cats_to_show = ‘1 2 3 4 5 6 7 8′;

So this solved my first quest. All the posts are only displayed in the actual Gadget Category, and not on my front page at all! Super.

Part II

Now, let’s look at the second part. I had no idea if this existed but I wanted a sticky at the top of the Gadget category page to describe what that page was about. For those of you that don’t know what a sticky is, it’s something commonly found in message boards which ’sticks’ a post at the top of the page, so it’s always at the top. So I found a plugin called ‘Adhesive’.

Link: http://www.redalt.com/wiki/Adhesive

This plugin was very easy to use and install. Just download the PHP file and upload it to your plugins directory and activate the plugin. In the options I selected ‘Show sticky posts only on category pages’. Then to make a particular post a sticky, select the category you want it in, in my case Gadgets, then check the ‘Sticky’ checkbox under the ‘Post Status’ section.

Now I have the sticky on top of my categories section. Awesome.

Part III

This part didn’t take much thought as I already knew how to do it. All I had to do was add a link to: http://www.ashbaughonline.com/category/gadgets/ in the header.php file in my theme.

Thanks for reading. Hope this post can help others that might want to acheive a similar effect.

Leave a Reply

Thanks For Visiting!