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?
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 a301 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 ?