Page 1 of 4 123 ... LastLast
Results 1 to 10 of 39

Thread: Permalink problem

  1. #1
    Kathy is offline Hello World
    Join Date
    Feb 2009
    Posts
    52

    Default Permalink problem

    I used the custom structure /%postname%/

    but when I click on a category link, I'm getting this

    /%category%/%postname%/

    and what's odd, category shows as the actual word category, and not the name of the category

    Yep, I'm confused

  2. #2
    Ryan's Avatar
    Ryan is offline WordPress Legend
    Join Date
    Jan 2009
    Location
    New Zealand
    Posts
    2,797

    Default

    I think you are using the wrong terminology.

    By "Category link" are you referring to the URL for the category? In which case it would not show a post name, since a category is not a post itself.

    And if it is showing the word "category" then it would presumably be the following (missing the %):
    /category/%postname%/

  3. #3
    chipbennett's Avatar
    chipbennett is offline WordPress Legend
    Join Date
    Feb 2009
    Location
    St. Louis, MO
    Posts
    1,992

    Default

    It should work, as Ryan pointed out above.

    However, note this strongly emphasized point in the Codex [emphasis in original]:

    %category%
    A sanitized version of the category name (category slug field on New/Edit Category panel). Nested sub-categories appear as nested directories in the URI. Starting Permalinks with %category% is strongly not recommended for performance reasons.
    WP TurnKey - Turn-Key WordPress installation and maintenance services
    WordPress user since 2005 | @chip_bennett | chipbennett.net | cbnet Plugins

  4. #4
    Ryan's Avatar
    Ryan is offline WordPress Legend
    Join Date
    Jan 2009
    Location
    New Zealand
    Posts
    2,797

    Default

    Thanks for pointing that out Chip, I wasn't aware of the performance issues associated with doing that.

  5. #5
    andrea_r's Avatar
    andrea_r is offline WordPress Rockstar
    Join Date
    Jan 2009
    Location
    Eastern Canada
    Posts
    1,325

    Default

    I think the OP is looking at category archives on the front end.

  6. #6
    chipbennett's Avatar
    chipbennett is offline WordPress Legend
    Join Date
    Feb 2009
    Location
    St. Louis, MO
    Posts
    1,992

    Default

    Quote Originally Posted by andrea_r View Post
    I think the OP is looking at category archives on the front end.
    I don't think so. If it were a category archive URL, it would look like www.url.com/category/%category%/ not www.url.com/category/%postname%/

    Even clicking on a post permalink from a category archive would end up displaying the single post, using the post permalink structure, not the category archive permalink structure.

    Oddly (given the stern warning linked above), the Codex listing displays the following image:



    Note the custom permalink structure displayed.
    WP TurnKey - Turn-Key WordPress installation and maintenance services
    WordPress user since 2005 | @chip_bennett | chipbennett.net | cbnet Plugins

  7. #7
    Otto's Avatar
    Otto is offline On The Rocks
    Join Date
    Apr 2009
    Location
    Memphis, TN
    Posts
    862

    Default

    Quote Originally Posted by Ryan View Post
    Thanks for pointing that out Chip, I wasn't aware of the performance issues associated with doing that.
    You shouldn't start the permalink string with any of %postname%, %category%, %tag%, or %author%.

    All of these cause the same performance impact, which is known in the code as "use_verbose_page_rules". Basically, when you use one of those as the starting piece, the rewrite matching system has to generate individual rules for every Page, then check those first. If you have lots of pages, this is a big hit to the system. In some cases, merely generating the list of URLs to check has been known to cause timeouts or SQL query size problems, which can lead to gigantic page generation times on the front end.

    If you don't have lots of Pages, it won't hurt you much. By "lots", I'm talking in the 50+ range of Page count.

  8. #8
    andrea_r's Avatar
    andrea_r is offline WordPress Rockstar
    Join Date
    Jan 2009
    Location
    Eastern Canada
    Posts
    1,325

    Default

    AHA! So that's why a ton of Pages get all those rewrite rules. huh.

    Otto is my favorite person right now. I'd run up against this but didn't know *why* or in what situations it would affect things.

  9. #9
    Otto's Avatar
    Otto is offline On The Rocks
    Join Date
    Apr 2009
    Location
    Memphis, TN
    Posts
    862

    Default

    I can illustrate this rather simply, actually. Consider this site:

    Page named "AAA"
    Page named "BBB"
    Page named "CCC"
    Bunch of posts with permalink "%year%/%postname%"

    Page rewrite rules will basically be the following:
    example.com/robots.txt
    example.com/feed/*
    example.com/comments/* (for comments feeds)
    example.com/search/*
    example.com/category/%category%
    example.com/tag/%tag%
    example.com/author/%author%
    example.com/%year%/%month%/%day% (with each of those after year being optional)
    example.com/%year%/%postname% (this is the permalink string you define)
    example.com/%pagename%

    The way that system works is that it compares to each of those URLs in turn, from the top of that list to the bottom. When one matches, then it knows what to display and what templates to call and such.

    The thing to note is that the order is significant. Every one from the top down is *less* specific than the previous one. Note that it also knows year/month/etc should be numeric. So a non-number won't match %year%. And then finally, %pagename% matches everything, but fails in the query, thus tripping the 404 condition.

    But if you define your permalink string with one of those four non-numeric fields, then that method will never reach the pagename rule, will it? If it's /%category%/%postname% now for example, then the %category% will match anything just as well as %pagename% will. It's just a string, and a user defined one at that. So the rules now have to be more verbose, and they change to these:

    example.com/robots.txt
    example.com/feed/*
    example.com/AAA
    example.com/BBB
    example.com/CCC
    example.com/ (this is a root rewrite condition, to recognize the site root page)
    example.com/comments/* (for comments feeds)
    example.com/search/*
    example.com/category/%category%
    example.com/tag/%tag%
    example.com/author/%author%
    example.com/%year%/%month%/%day% (with each of those after year being optional)
    example.com/%category%/%postname% (this is the permalink string you define)


    Same thing as before, except the pages moved up in the list and are now individually specified. And the resulting list has the same property: The list gets less and less specific as you go down it, until the last rule can match anything. Remember that %whatever% is basically considered an optional field in all cases. example.com/something would give you a category archive for the "something" category with the above setup.

    And that's how the rewrite system actually works. :)

  10. #10
    Kathy is offline Hello World
    Join Date
    Feb 2009
    Posts
    52

    Default

    OK, sorry it took me so long to get back. You don't want to know why, LOL.

    First, I was tired when I posted. I should have included a link to the site.
    It is still a work in progress.
    http://waynecountynow.org/

    I used custom structure, /%postname%
    I did NOT use /%category%/%postname%/

    Yet if you go to the site and click on a category, like Activities, this is what I get
    http://waynecountynow.org/category/activities/

    Note the word category inserted in the middle

Page 1 of 4 123 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •