WordPress Category Titles

Comments 14

There are a few “functions” that already exist in WordPress which can be put to good use if you know about them. I found out about this one and started using it about a week or so ago but just haven’t had time to write it up as I’ve been busy on other things. This particular one may be useful for people from a “presentational” point of view.

It would appear that when you select a category (from the list in my menu) there is a “function” that can show the category title. As it already exists there is no “hacking” involved at all. You just need to place a call to the function wherever you want it to appear on your page then give the call it’s own div so you can style it in your CSS. If you want to see what I mean just select a category. Now I don’t want to pressure you but if you select the “WordPress” category you will still have this post in front of you. See the nice “WordPress” title at the top? Wasn’t there before was it?

Editas I no longer use WordPress I’m afraid you won’t be able to see this in action. Just take my word for it that it works.

So here’s how you do it. This is the function as it already exists:-


So if you use an “if” statement to determine whether a category has been selected or not and an “echo” to print it’s name to screen, you can place a call in your index.php file which will only show when someone has selected a category. So you end up with this:-

if(isset($cat)) {
echo get_the_category_by_ID($cat);

Now remember that this is PHP so you need to surround it with the opening and closing PHP tags (or put it inside existing PHP tags though this may make styling difficult) and then surround the whole thing with “div” tags. I happen to have called my “id” “category” which seemed logical at the time. You can call it what you want then you can style the “id” to your hearts content in your CSS. Simple really!

My thanks to Janne at Nomadig for pointing this one out.



  1. Thomasso

    Yup, I'm finding a whole pile of stuff too. I was looking through Kitten's and Nuk-Moose's weBlogs, they got a many nifty little things you can do too. I added some plguins and changed some php code in the index.php file yesterday. See if you can findout what got changed... :dance:

    Also, I saw for the first time your RSS link on your freinds "janne's" site. I'm going to RSS one of your posts just to see what heppens? :think:
  2. Thomasso\'s weblog

    Getting the RSS feed thingy figured out!
    This is just another test to get the RSS Feed going. I was over at Stuart's weBlog and notice that he was using the RSS / Track Back /ping on one of his friend's website. So here it goes. This is a RSS feed from Stuart's page on his last Blog entry....
  3. Stuart

    Well that seems to have worked Tom. :clap: I'll have to come over and see if I can spot your changes. I'm just so busy at the moment I'm really not doing too much surfing. :boohoo: I keep Kitten's devblog on my feed reader so I can catch the new stuff. I've only really glanced through Moose's site. Must spend a bit more time on it. :doh:
  4. Shadow

    Hi Stuart,

    Sorry to ask - I realise you are busy - but could you spell this procedure out in 'dummy' terms. I cannot find reference to
    `get_the_category_by_ID()` in my index and not sure where
    `if(isset($cat)) {
    echo get_the_category_by_ID($cat);
    }` is actually placed.

    Thanks for any advice you can offer :oops:
  5. Stuart

    _Email reply sent_.
  6. Shadow

    Thanks for all your help Stuart.

    I have it running on my site now nd it is just what I was after...

    Thanks again for sharing :clap: :notworthy:
  7. Stuart

    Nema problema. It's Janne you should thank though. It's his _eagle-eye_ that spotted it.
  8. Kunjan

    This is great work!

    I had problems with the run over menu on my site too.

    But since I have a custom CSS... So can you point out what was the problem with the run-over menu and how to fix it?

    That would be great.
  9. doug

    what about displaying the 'month, year' as a page title on the monthly archive pages?
  10. doug

    ah, i see this is moot for those who have adopted the 'nicer archives' plugin.

    in my case, the blog does not utilize categories or multiple authors, and i need the excerpt displayed, so this kind of archive is not a great match.
  11. pinkasphalt

    Categoray Titles
    I found a great tip over at The Bombsite that does something that I had been wanting to do. It allows you to display the category title on a category archive page. So if you click on the Wordpress category link at the end of this post, the next page w...
  12. Stuart

    Thanks to everyone for the links.
    @Doug - you spotted the "nicer archives" then. I'll have a look at your problem when I have time. I'm a tad busy just now. I'll let you know if I find anything.
    @Kunjan - I see you use a "fixed-width" layout. I'm doing a piece on the principals of this "fix" but my expertise (if you want to call it that) is with the fluid-type design. The principals are the same but I think the application is slightly different. You could take a look at Root's "Gemini Interface" and compare how the extra divs and related CSS apply to your site.
  13. kpont.com

    Showing category titles in WordPress
    Stuart at the bomb site weblogshows us how to make category titled show up in WordPress.

    Hat tip: Wordblog

Commenting has expired for this article.

← Older Newer →