How To Add Custom Text in a Wordpress Blog Category Page
Posted by Mrs. M on 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? ![]()













Recent Comments