Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 762
mc77de Avatar asked Oct 18 '25 19:10

mc77de


2 Answers

The simplest way to make your page url like www.example.com/se/se1 instead of www.example.com/se1 is to create page se and se1 make as child page of se.

With this option you'll saved your wordpress website permalink structure, you'll in not need to change your other pages redirects for google indexing

like image 154
Sukhjinder Singh Avatar answered Oct 20 '25 15:10

Sukhjinder Singh


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);

like image 22
mc77de Avatar answered Oct 20 '25 17:10

mc77de