This unique WordPress hack will allow you to index tag pages you create without having to create template files for each and every one.
This post is part of 30 WordPress hacks in 30 days.
Back in WordPress Hack #15: Hacking WordPress Tags I described how to add “tag support” to your WordPress theme files, and how to add a “tag cloud” like the one I use on this blog in the bottom of the left sidebar. When you “tag” pages you are actually creating additional pages in your blog – that can get indexed by search engines.
For example, let’s say that I create a new post about an iPod. I put the post in the “gadget” category, and tag it “iPod” and “mp3 player”. Within the WordPress paradigm many things happen…
- A new post page is created based on your single.php theme file using the post title as permalink
- The post is added to the top of your blog home (usually your index.php home, unless you changed it – like I did)
- The post is added to the appropriate archive pages for day, month, year, etc.
- The post is added to all “category” pages you assigned it to
- The post is added to all “tag” pages you added it to
If you read WordPress Hack #18: WordPress Template Files, you already know that you can create custom “tag” and “category” pages, so when the old google crawler comes a-knockin’ it will find original content and not penalize your blog in search rankings. The problem normally is – if you’re a prolific blogger, you (like many of us) may have a few dozen categories, and hundreds (if not thousands) of tag pages.
When you categorize a post, you can find it within your blog at:
www.site.com/category/cat-name
When you tag a post you can find it within your blog at:
www.site.com/tag/tag-name
To create a custom page for any category or tag page, all you have to do is use your index.php or single.php to create a new WordPress theme file. Open either index.php or single.php in a text editor and “save as” either:
category-id.php (for category pages)
or
tag-slug.php (for tag pages)
This means if my “gadget” category was “17” then my theme file for it would be “category-18.php”. If my tag was “mp3 player”, then my theme file for it would be “tag-mp3-player.php”. View my WordPress Template Files hack page for pics and a better description.
So – What “I” did was create category theme files for every category I had. THEN, I created a single “tag.php” file that would display for every tag page I have. What I didn’t mention up until now was that if you create a “category.php” and “tag.php” file and put them in your theme directory that these will be used for ANY category or tag pages that don’t already have one for that slug or ID.
Every blog is of course a different topic (or niche), but this is what I did for tag pages on one blog I own. I used the tag title to create a different description lead-in sentence to get each tag page listed in the search engines. Right before “the loop” I placed this bit of code to do that:
!
My blog is about geeky tech stuff, technology, Linux,
gadgets, web tools, and more!
,
the posts below should be right up your alley!!
That code gets the “tag_title” and uses it like this (for the example “mp3 player”):
“This page is about MP3 Players! My blog is about geeky tech stuff, technology, Linux, gadgets, web tools, and more! If you like MP3 Players, the posts below should be right up your alley!!”
I did this a month ago on one of my blogs, and all the tag pages are indexing nicely! I’m sure you could hack this up even further – but this simple little solution fixed my tag page indexing problem quickly.






Yikes… I think you might’ve missed a code tag in your post?
Erikas last blog post..Miami Web Design
fixed now – thanks! =)]
Another great tip which i’m implementing right now!
Question thou : how do you trunticate your listings in the Tag Page order to avoid duplicate content?
Hey man – Glad to see your back!! Either I missed a bunch of posts, or you took a vacation!
Mark
Mark – The Niche Store Builders last blog post..Creating your Own little WordPress Playground
Hi JT, First time here and I’ve enjoyed your posts, full of lots of info. will have to come back and read a couple of others that I thought looked interesting. thanks so much . I also wanted to let you know your Entrecard will be on my blog tomorrow, so many thanks for that. =
@jj-momscashblog – thanks for the kind words, glad to have you here! =)]
@Mark – thanks for the comment! No – I didn’t post at all last week and only once the week before (too busy!).
@Anthonyq – I don’t truncate the listings on my tag page (other than maybe excerpt) to avoid duplicate content, it’s just not any issue (in google) anymore.
Ah ok. I was looking on your blog here, i noticed that the listings were summaries. Wondering how you do that?
Love these posts. I’m saving them all for when I may be confident enough to hack without destroying. 🙂
Dennis Edells last blog post..Grab Your Offline Marketing Tools Here Too!
@Dennis – I would read showing only a post excerpt in WordPress.
Hi JT,
First time here and I’m impressed of the quality and thoroughness of your posts! – Thank you!
As you can probably quess (See my last post below), I was especially delighted of your Sample code for:
“That code gets the “tag_title” and uses it like this (for the example “mp3 player”):”
I’ll try it, definitely!
Unfortunately, I have to add like Dennis did, that:
“Love these posts. I’m saving them all for when I may be confident enough to hack without destroying. :-)”
– Personally I have a lot of experience in distroying when I intended to be building up!
Again: Thank you!
I’ll be back!
B.T.W. Here’s my last Post:
http://zuneitman.com/underwater-mp3/freestyle-audio-sonic-waterproof-headphones/
.-= Phil´s last blog ..American Hawks Explorer Metal Detector w/ Waterproof Search Coil, Headphone, Bag, Batteries =-.