Support » Fixing WordPress » Categories and Static Pages

  • This is a question different from the ones asking to put pages under categories. I understand that the v1.5 “pages” concept is to create static pages.

    A lot of people are using Pages to distinquish their different categories. This applies to me, too. But I’m confused.

    If someone clicks on a link to, say, the Archives Page (physical page representing the category: archives), and then they click on the category in the sidebar “archives” or from one of the category listings in a post (Filed under: Archives), which page do they go to?

    I want to keep the categories on their own pages since there is static information related to each category, which makes the static pages wonderful. But what if someone bypasses the static page by using the category link?

    See my confusion? How can we clean this up?

Viewing 15 replies - 1 through 15 (of 18 total)
  • If someone clicks a Category link (from anywhere), they will be taken to a list of Posts belonging to that Category.

    If someone clicks a Page link (from anywhere), they will be taken to that Page. Again, here I mean “WordPress Page” – the “static” (another misnomer) Post-like feature in 1.5

    If you don’t want people to follow the Category links, don’t give them the option:

    Just list the Pages on your sidebar (using wp_list_pages). Don’t list the categories (take out wp_list_cats or whatever tag is being used). That way no one can ever “bypass” your static pages.

    I’m not clear on what you’re trying to do, though, when you say [you] “are using Pages to distinquish their different categories”.

    If you want to organize or style your site differently, or display different static content when a particular category is displayed, you might try nixing the Page idea and implement the following.

    CASE 1: You want some text displayed before all the posts when a user follows any any Category link (i.e. the same text for all categories).

    Create in your theme directory a file called category.php. Actually, you might want to copy archive.php or index.php or page.php over to this new category.php so you don’t have to write as much code, just alter it instead.

    At any rate, this is the template that WordPress will reference whenever a Category link is followed (see next post for a detailed description on what templates WordPress tries to use in this situation). Above The Loop, put in <div id="sticky-snip">This is some text that will always display when any Category link is followed</div>


    CASE 2: You want different text to display above the list of Posts from the Category depending on what Category the viewer is looking at. Example: Display “These posts are all about cheese” for the “Cheese” category, and “I am not wearing any pants” for the “Shorts” Category, and “The following is a list of posts about some particular topic” for ALL OTHER CATEGORIES.

    Rather than making a template with lots of if statements, WordPress allows you to do the following nifty trick.

    Create category.php as above. Put
    <div id="sticky-snip">The following is a list of posts about some particular topic</div>
    above The Loop.

    Figure out the Category ID of the Cheese Category. Say it’s 6. Create category-6.php as above. Put in
    <div id="sticky-snip">These posts are all about cheese</div>
    above the Loop.

    Figure out the Category ID of the Shorts Category. Say it’s 19. Create category-19.php as above. Put in
    <div id="sticky-snip">I am not wearing any pants</div>
    above the Loop.


    See for more details about WordPress Templates.

    In either of these cases, you just need to list the Category links with wp_list_cats. No Pages are needed. WordPress uses these new templates automatically.

    EDIT: As I said, I don’t quite know what you are trying to do, so perhaps this does not address your issue at all.

    Which template does WordPress use for a Category with Category ID = 6?

    The first template it finds from the following list:

    1. category-6.php
    2. category.php
    3. archive.php
    4. index.php

    This is wonderful and might solve my problem. I write notes and descriptions about the specific categories to direct people since our site is so vast. Let me poke at it for a few days and I’ll let you now how badly I’ve mangahhhlllled my test site.

    I already accidently put the permalink code in the htaccess of the root of my site and not the wordpress test directory and totally had my site screwed up for two weeks because I didn’t “look”….ain’t this fun.

    Let me know. I plan on putting this into Codex.

    I have a related question: I’m trying to use WP1.5 as a basic CMS for a nonprofit advocacy organization. I’m using the static pages for content that won’t be changing frequently, and am looking to use the posts for easily adding frequently updated content.

    As such, I’m using different post categories for each section or “function” of the website. So I have a category for press releases, one for this week’s legislative committee schedule, one for our lobbyists’ daily journal, and so on. Having a separate category template for each of these sections is absolutely essential, since I would like to include different sidebar information for each type of information.

    My questions:
    –>Is there a way to have specific post templates for each category?
    –>Can you have a specific template sub-categories, also?
    –>What would each be named?

    Thanks so much for your help!

    See Cateory Templates on this page in the Codex:

    Thanks Moshu!

    I forgot about the custom page templating, but what I was looking for was a way to have specific post templates be used automatically…I guess I’m not convinced that the folks who will be doing the postings will select the correct template and such (it’s hard enough to have them select the proper category).

    I wasn’t sure if the the category-XX.php template system had been expanded for subcategories or if there was a way to “force” post templates for specific categories and subcategories. If it’s too much work, I’ll probably just invest the time in training and monitoring…I was just hoping to make it as idiot-proof as possible.


    I am feeling foolish, but I have followed all mdawaffe’s instructions for Case#2, but still don’t get the sticky’s showing up. I am stumped by what you mean when you say “In either of these cases, you just need to list the Category links with wp_list_cats” . Is there any chance someone could walk me through that? I am using a template.

    The tag wp_list_cats has step by step instructions on the Codex on how to list your categories, including excludes and such.

    I have over 30 different category-x.php files on my site and it is working like a dream. I only created these “special” category templates for the categories that I wanted to put some html text on that basically said: <i>This category is about X, Y, and Z</i>.

    I have single custom sidebar for every one of these category pages that is different from the rest of the posts (similar but different) and customizing these to “look” different is really easy.

    I don’t know what you mean by “sticky” as these are just category pages. A “sticky” is the effect of forcing a post to rise to the top of the Loop listing of posts and is, as far as I know, only done through the use of a plugin like Adhesive or something like that. Check for new sticky-plugins.

    Don’t know if this is of any relevance, but here is a quick way to have your category description appear on top of category pages (mdawaffe’s case 2) without multiplying your template files.

    Put the following outside the loop in your category.php template file:

    <?php if (!('' == category_description())) : ?>
    <div class="categorydescription"><?php echo category_description(); ?></div>
    <?php endif; ?>

    Style at will, and voilà! The category description is the one you enter in the admin area. It accepts basic HTML, as far as I can tell.

    I’ve read all the above. I’d like to have a category page with all the posts in that category listed in the side bar. Each category would have the same layout with different content and sidebar listings.

    Is there some way to use a single “category.php” and have the sidebar php ask for the posts to list? I was going to copy the page.php, add the code above to list the “category description”, and have a new sidebar.php to query the posts list of the category. Can I add a generic php query to just list the posts in the sidebar? I don’t need anything else there.


    okay so by using the category-5.php, i could have a specific category display a different template. Now how do I tell it to use a different template?

    I forgot to add:

    Would this mean that any post under that topic would use that specific template?

    It would be nice if the codex had full instructions on what needs to be in category-X.php.

    1. You don’t have “to tell” anything: WP knows what to look for… see Template Hierarchy in Codex.

    2. Depending how do you build your template(s). See detailed instructions and examples in this thred


Viewing 15 replies - 1 through 15 (of 18 total)
  • The topic ‘Categories and Static Pages’ is closed to new replies.