1

How can I create two different permalink structures for a Wordpress blog, determined by an addition to the post meta?

On the old site, articles were available through the following structure:

/index.php/site/articles/[sanitized-title-with-dashes]-[ID] (Note the lack of a trailing slash, the bloat before the article title, and the ID)

Naturally, since we're transitioning to Wordpress, I want the new articles to have their own permalink structure:

/%postname%/

Would be it possible to write a function in the theme that, when processing the permalinks, it uses the old structure for posts I've marked as "Legacy" in the Post Edit page. Otherwise, the permalink will be the new structure.

I've already tried the Custom Permalinks plugin, but it can't seem to properly reconcile the old ugly structure with the new one. This was true even when I "conceded" and tried making the new permalink structure index.php/%postname%/.

I'll have no problems creating a new post meta to tell the system whether to apply the old permalink structure or not. The question is, where do I start with setting the permalink in the first place?

1 Answer 1

2

I think your approach is not the good one. If I understand well, What you want to do is keeping the old permalinks for the old posts and stick with them, while having the new permalinks only for the new posts.

You should consider having the new permalink structure for all the posts (old and new), and writing a rewrite rule to keep the old links working. For example rewrite /index.php/site/articles/[sanitized-title-with-dashes]-[ID] into /[sanitized-title-with-dashes]/. This way, you can send a 301 Moved Permanently to search engines and have only one permalink structure within Wordpress. This will remove the pain and you will not have to bother again about those old permalinks.

Does this sounds good to you ?

4
  • 1
    I'm ok with any approach, so long as I get to retain the hundreds of thousands of FB likes and comments associated with the old URLs. Is there a rewrite rule that uses moved permanently for search engines, but keeps the old structure "valid" so FB likes and comments (which are based on URLs if I'm not mistaken) are retained?
    – ricotheque
    Jun 21, 2013 at 23:14
  • OK, in this case it's different. FB would probably consider your new permalink as a new page, and loose the old likes, but I can't be sure of that (FB doc sucks). Why not use add_rewrite_rule to rewrite your old permalink internally ? You could even add a parameter to change the canonical URL meta tag and keep the old permalink as the canonical URL of the old articles. Jun 23, 2013 at 20:38
  • Sorry it took a while for me to get back to you. Trying this now, let you know what happens and thanks!
    – ricotheque
    Jun 30, 2013 at 2:36
  • Turns out the index.php wasn't in the old structure after all, so I was free to use the Custom Permalinks plugin linked above. It took a while to change all of the permalinks of the old articles, but at least it was a one-time thing. Thanks for the help! :)
    – ricotheque
    Jul 29, 2013 at 10:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.