Web Analytics Made Easy -
StatCounter [Wordpress] Different post permalink depending on category archive - CodingForum

Announcement

Collapse
No announcement yet.

[Wordpress] Different post permalink depending on category archive

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • [Wordpress] Different post permalink depending on category archive

    Anyone familiar with Wordpress around here? (but I guess this could as well be a general PHP question)

    A little background info:
    If the permalink settings are set to /%category%/%postname%/ you can access a post that is assigned to multiple categories at different URLs; for example post XYZ is assigned to category “foo” and category “bar”, you can access this same post at http://example.com/foo/post-XYZ and http://example.com/bar/post-XYZ (of course, it will have a single canonical link to not be considered as duplicate content).

    Now, you can have category archives that list posts of a certain category, for example http://example.com/category/foo/ will list all posts assigned to category “foo” etc. Here is what I want: If a post appears in multiple category archives (because it’s assigned to multiple categories) I want the URL to the single post to be different, according to the archive I’m currently viewing. So, in the archive for category “foo”, post XYZ should have the URL http://example.com/foo/post-XYZ and in the archive for category “bar” that same post should have the URL http://example.com/bar/post-XYZ

    How is this possible?
    Stop solving problems you don’t yet have!

  • #2
    Whilst my wordpress experience has been nothing but negative, with that steaming pile of ignorance, incompetence, and ineptitude being something I would NEVER allow a client to deploy in the first place...

    Your question's probably correct answer is unrelated to the system itself. Because the answer in most cases is "DON'T DO THAT!"

    Why? The duplicate content penalty.

    This is not something any CMS should do, nor that anyone should create mods/plugins/extensions/whatever other name is hot and trendy, because it opens up an ugly can of worms when it comes to search and what you have to do to make search not pimp-slap you for it.

    Having the same content available at multiple URI's is confusing, inconsistent, but worst of all looks to search engines like you're trying to game the system. If such a URI scheme were implemented you'd likely have to either block all of them from search, or selectively eliminate specific copies from being indexed. This is a royal PITA if you don't have a common "master" URI that would always be in use separate from your "categories" masquerading as directories. I mean you can try to play games with robots.txt or using "canonical" but that only goes so far and the more pages you have doing it, the more of a mess this could become.

    Hence my advice is "Just don't go there". You're gonna screw yourself when it comes to how search treats that.
    I'll kill you and your dreams tonight, begin new life.
    Bleed your death upon me, let your bloodline feed my youth.
    https://cutcodedown.com

    Comment


    • #3
      As I wrote in the first post, there is a canonical link that will point to a default URL, so duplicate content should not be an issue here. The reason for this is mainly because I need the system to know which menu item to mark as “current” when viewing a single post that is in multiple categories. So, I thought that the most reliable way would be to read the category string from the URL which is why I need different URLs, depending on which category archive the user came from. And the URLs are already there by default, it’s not like I went through hoops to achieve that. I just need them to be reflected in the template now.
      Stop solving problems you don’t yet have!

      Comment


      • #4
        Would it not then need to mark MULTIPLE categories based on the needs of the content? I'd think marking just one as current would be more confusing if it's listed under a bunch of them. Pull the list of categories for the article, and then do a compare against that list during menu generation so that ALL the relevant ones are highlighted, not just the one.

        ... and just having canonical set doesn't prevent dup content penalties if they're all 200'ing. Such prevention techniques are an unreliable mess.

        But overall it sounds like you're trying to mess with the URI instead of handling it properly server-side from the page's information.
        I'll kill you and your dreams tonight, begin new life.
        Bleed your death upon me, let your bloodline feed my youth.
        https://cutcodedown.com

        Comment


        • #5
          OK, let me explain it this way: basically the site is consisting of multiple general areas (kind of like “sub sites” inside a global website), and each section has a different color scheme. Usually posts are either in one or the other area but occasionally it can happen that a post is supposed to show up in both areas. I want the user experience to be as consistent as possible so that the visitor isn’t surprised by a sudden change of the color if they access a post in one area that technically belongs to both areas.

          The page’s (post’s) information always contains all of the info, there is no distinction other than the URL, that’s the issue.
          Stop solving problems you don’t yet have!

          Comment


          • #6
            Could you test it by referrer and/or track via the session? Might be a better answer. Wouldn't be an answer though if they navigated off the different coloured page...

            This is why I dislike these types of stylistic stunts. They just lead to pulling dumber and dumber stunts that require even dumber stunts as a site ages.
            I'll kill you and your dreams tonight, begin new life.
            Bleed your death upon me, let your bloodline feed my youth.
            https://cutcodedown.com

            Comment

            Working...
            X