I have a page with with address localhost/ . .In the navigation bar I have a new page link named Blog. SO wheni travel to that page the link is localhost/blog . Now here is my thing ...when i click on any post of that page the next page permalink become localhost/{The-post-name}. what i want is to print the link fully... like /localhost/blog/{the-post-name}. for every post i walk through this page


Just go to Settings > Permalinks, select Custom Structure and enter the following:


That will add /blog/ to the beginning of post names in their permalinks. This will not affect Pages.


You can add a rewrite rule to WordPress:

add_action( 'init', 'wpse_328813_rewrite' );
function wpse_328813_rewrite()

What that is saying is, "WordPress, when someone requests a URL with "blog", followed by a slash, and then some text, maybe followed by another slash, try to load a page matching that slug. Oh, and do this before you try any of your other rewrite rules."

  • Massive overkill. You can achieve the same thing for posts just by changing the settings in Settings > Permalinks. – Jacob Peattie Feb 15 '19 at 11:14
  • We must have different understandings of the word, "massive". A custom permalink structure in the menu does make more sense for what he said. I just jump to rewrite rules because they are more flexible, and invariably the person will come back with, "Oh, well what I really meant was only if..." – tmdesigned Feb 15 '19 at 11:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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