Custom post types and permalinks : What a mess !

I know that’s a common problem with the custom-post-types, but I’m stuck there. I created a custom-post-type named ‘cpt_soins’. I have no page with similar name (singular/plural)…

I tried with
'rewrite' => array('slug' => 'nos-soins-et-services');

when I registered my custom post type in order to display a more pretty url than “/?cpt_soins=soins-visage-a-la-rose”… But I’m stuck with a 404 error.

I want this ugly permalink: “http://localhost:8888/wordpress/?cpt_soins=soins-visage-a-la-rose” —> transformed into: “http://localhost:8888/wordpress/nos-soins-et-services/soins-visage-a-la-rose”

I know i can use the “add_rewrite_rule() with regex”. But I did’nt get working. Could you give me the code please for the functions.php in order to get my permalink ?

Thanks a lot

5 Answers
5

Change this:

'rewrite' => array('slug' => 'nos-soins-et-services');

To this:

'rewrite' => array('slug' => 'nos-soins-et-services', 'with_front' => true);

Leave a Comment