How To Add Custom Text in a Wordpress Blog Category Page
Wordpress, templates, tips January 10th, 2008Here’s a quick article on adding custom text to a categories page for your Wordpress blog. First, a little background.
Wordpress sorts your blog posts into categories. See here for the definition from Wordpress. Wordpress also has something they call a “template hierarchy.” A good explanation comes from Tina Gasperson’s blog:
Because most WordPress themes have a single template for archives, aptly named archive.php, it’s not immediately apparent how to place a text ad on a specific category results page. But never fear: by default, WordPress searches using what it calls a “template hierarchy.” By taking advantage of the template hierarchy, it’s easy to make a special page that keeps your text ad where it belongs.
The template hierarchy works like this: if your visitor clicks on category #3, WordPress first looks for the most specific template: category-3.php. If it doesn’t find that, then it goes after the more generic category.php, and then archive.php, and if it doesn’t find that, it finally drops back to index.php. Armed with this knowledge, you can create a category-specific template using archive.php as a base.
Yes, armed with the knowledge of how Wordpress works, you can guide the system using this template hierarchy. You can make Wordpress show special text on certain category pages. This is not a difficult task, but I will assume that you know about coding and are familiar with the Wordpress format. This is how you do it.
So let’s say you want to post some text (for example, a text ad) under a certain category– but not all your categories. Let’s say you want to post a text ad under your category named “blogging.” Wordpress calls this category “blogging,” but Wordpress also assigns an Identity Number to this category, too. You need to find this ID number before you can do anything.
Log in to your Wordpress blog and go to “Manage” and choose “Categories.” You’ll see your list of categories. Since we are going to alter the “blogging” category, look for it in the list. Look for the ID Number.
In the image above, the ID Number we want is 73.
Now, go to “Presentation” (somewhere to the right of “Manage”) and choose “Theme Editor” tab. You will probably have a different theme than I, and your php files will look different, too. But the basic bones should be there. In the “Theme Editor” screen, look to the right-hand side and you’ll see a long list of links. Listed here are php files, like Style sheet, Header, Main Index Template, etc. Don’t worry if you don’t have the same ones that I do, or vice versa– it really depends on the theme you are using. However, some files should be the same. Just like people all have heads and eyes but different hair and eye color… your theme should have certain “body parts” but the styles may vary. Look for the php file called “archives.php.” Click it. When the page reloads, make sure it says “Editing “archive.php” at the top.
Copy all of the code in this file. Now, open up a new Notepad file. Paste the copied archive.php code into this new Notepad page. Now you are going to save the Notepad page, but you need to rename it using the ID Number of that category you wanted to change. Remember how our “blogging” category has an ID if 73? This is what I named my Notepad page:
Be sure to name your file exactly that (just use your own ID Number for your own category). Make sure there is a hypen and make sure you have the .php. Save the Notepad file but don’t close it yet!
You need to put in your text ad. Grab your text and paste it in like this (mine is in red):
<?php get_header(); ?>
<div id=”primary-content”>
<?php include (TEMPLATEPATH . ‘/theloop.php’); ?><p>
The kinder, gentler computer geek, <a href=”www.mrsmecombersscrapbook.com”>Mrs. Mecomber</a>, has recently issued her top ten free software programs for 2008.
</p></div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
Do you see how you are inserting your code between these two lines of code?
<?php include (TEMPLATEPATH . ‘/theloop.php’); ?>
</div>
Of course, your text ad will be different, unless you want to give me some free advertising.
Now, save your Notepad file again. Upload this file into your FTP program. Go back to your Administrative page in Wordpress (you may need to refresh or click a link elsewhere and come back to the page). You should now see your “category-IDNUMBER.php” file in the right-hand side.

You’ll notice that the Archive files remains unchanged, too.
Your text should now show up in only that category page. Ain’t Wordpress fun? ![]()












January 11th, 2008 at 1:33 am
Hey this post is sooooo easy to understand. Way too cool. Thanks for posting the instructions. Even a dummy like me can understand
January 11th, 2008 at 2:15 am
No problem!
I hope this helps out many people who have the same desire for their blog.
Thanks for visiting!
January 12th, 2008 at 12:28 am
I was just curious what it will look like after you do all that? Can you tell me the category in which you did that so I can see the the finished product?
January 12th, 2008 at 2:21 am
Hi, Lori. You can see the text here at this page:
http://newyorktraveler.net/category/blogging/
Scroll to the bottom and look for the line “Now is the time for all good men to come to the aid of their country.” lol.
January 12th, 2008 at 7:06 pm
Nice tip. I was going to do the exact same thing except more complicated. This simple solution is so much better. Thanks for the info.
February 1st, 2008 at 5:45 pm
I tried to upload the file into my ftp but it did not appear in my Wordpress Theme Editing page… I wonder where did I go wrong? Where do I copy the file to in my ftp? Under wp-content? I’m so confused…
February 1st, 2008 at 6:00 pm
Hi, Angeleyes. Sorry about your problem; let’s see if this will help.
Everyone has varying files and locations, because not everyone uses the same Wordpress theme and FTP program, and etc. But the basics are similar and should work. Try this:
In your FTP program, look for your “WP-Content.” Inside this folder is a folder called “Themes.” I have several smaller theme folders in my main Themes folder, so you’re going to have to find the one that you use for your blog. For me, I use the Theme “Unamed-One.” Funny name for a theme, but I love the design!
Anyway, put your newly made php file in that folder– in your theme that you are using.
To clarify:
1. Go to your FTP program.
2. Go to “wp-content.”
3. Go to “themes.”
3. Find the theme folder that you are currently using for your blog (mine is “Unnamed-One.”
4. Put your category-??.php file in this folder.
You’ll know you are in the right area if you see other php files that have titles like: archive.php, index.php, page.php, footer.php, style.css.
Once you have the php file uploaded, go to your Wordpress Admin area now, and refresh (or login if you haven’t already). You should see the new category-??.php file in the list, as I showed you with my screenshot picture. (Of course, my file was called “category-73.php.” Yours will be different, that’s why I typed it as “category-??.php.”
Let me know how this goes.
February 3rd, 2008 at 7:40 am
Thanks so much Mrs. Mecomber!
I was having problem saving the file as it kept appearing as .txt. Only after I asked my hubby that I know I have to save it as quote “category-xx.php” so it will appear to be a .php file.
Now my next problem is looking for Page 2…. where to find page 2’s category???? I’m really lost…
February 3rd, 2008 at 10:16 pm
Hi Angeleyes. Yes, sometimes those little errors can make a big difference. Glad you worked that out.
As far as Page 2, I am not sure what you mean by that. Because I am not familiar with your blog, it is hard to tell. Do you mean you have two pages with the same category? I don’t know how to insert text with that besides the file I showed you. I would think that the file would be applicable for however many category pages you had, as long as they were the same category (say, for all category pages listed under ID #73). In other words, a file for category-73.php would work for all pages in that category with that ID number. I haven’t tried it, as I don’t have more than one page with each category; but I don’t see how that wouldn’t work. If it doesn’t work for you, I recommend that you search the Wordpress forums for a specific answer. The moderators know more about specific coding for it.
February 5th, 2008 at 1:27 am
I think I’m going to give this a miss…. don’t want to work my brain for that! LOL
Anyway, thanks heaps for the valuable info!
April 7th, 2008 at 1:12 am
[…] How To Add Custom Text in a Wordpress Blog Category Page […]