Search code examples
wordpresspermalinks

How to use slashes in WordPress permalinks?


I am migrating an old website to WordPress. I have to migrate about 100,000 pages. I have written a plugin which is making use of wp_insert_post.

I also want to migrate the old URL structure without making use of redirects (because every 301 redirect is said to loose some link power), but use permalinks instead. Whenever I set a permalink which includes a slash (directory structure), the slashes are replaced with '-'. This is the problem.

wp_insert_post(array=>('post_name' => 'slashes/go/there/'));

permalink = 'slashes-go-there-';

Any ideas how i can set permalinks on a individual basis for every single page would be appreciated?


Solution

  • Finally I mangaged to solve the problem. Solution:

    1. Install a wordpress plugin: Custom Permalinks from Sami Ahmed Siddiqui

    2. Writing an entry to metadata to set the permalink:

      update_post_meta($wpid, 'custom_permalink', $url);