3

I want a permalink with slashes : e.g. http://mysite.com/keyword1/keyword2/mypage.html

I have put it in the param "post_name" in wp_insert_post but the slashes are stripped, so the result is http://mysite.com/keyword1keywordmypage-html (the dot is also replaced by -)

the keyword1, keyword2 are arbitrary values extracted from the post's content

how can i also add the .html without it being replaced

5
  • Of course they are stripped! Those are control characters. They are meaningful to the server and to the WordPress request parsing engine. If you had slashes in the title you'd get 404s.
    – s_ha_dum
    May 6, 2014 at 17:41
  • It's not the post_title but the post_name which is actually the slug
    – yeahman
    May 6, 2014 at 17:44
  • Yes, and hair splitting aside, the point is the same.
    – s_ha_dum
    May 6, 2014 at 17:45
  • mysite.com/keyword1/keyword2/mypage.html so you are saying that kind of permalink is wrong as slashes are control characters? i don't understand... I don't get your point
    – yeahman
    May 6, 2014 at 17:56
  • Yes, slashes are control characters. You cannot just add them to the permalink. Either the server or WordPress itself, depending on you permalink settings, will choke if you managed to add slashes to a post permalink in that way.
    – s_ha_dum
    May 6, 2014 at 18:02

1 Answer 1

4

You can use this plugin for .html extension https://wordpress.org/plugins/html-in-url/

And for slashes you should create page of 'keyword1' and 'keyword2' and make keyword2 as a parent page.

then u will get the slash url keyword1/keyword2

Your Answer

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

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