Right now I am working on one of my client’s project. Its all about amazon product display.
My client wants me to change the permalinks of all posts, pages, serch results, archive pages, categorypages, all custom post type pages.
I am very new to Rewrite API. I have read the documentation provide on wordpress codex here https://codex.wordpress.org/Function_Reference/WP_Rewrite and here https://codex.wordpress.org/Rewrite_API as well as on the interne but can’t able to make the things clear.
Can anyone help me to generate custom permalinks for my pages ?
Right now, Page url looks like http://mysite.com/?page_id=2 if its default permalink and http://mysite.com/sample-page/ if its post name permalink.
I wants the page url looks like http://mysite.com/info/sample-page.
Here info is static word I want to be added to my page url.
How can I achieve this ? Can anyone help me out in this situation ? I have already wasted my 2 days in this issue and I am sure its really simple for the one who already worked with this.
Quick help much appreciated.
Thank You,
Aezaz
There might be better ways using filters or apache/nginx rewrites, but here are two ideas to consider from the admin UI point of view (untested):
Idea 1:
You can always visit
/wp-admin/options-general.php
change the whole the site url:but I don’t think you’re looking for that, since this will also change the home url.
Idea 2:
You might therefore visit
/wp-admin/options-permalink.php
and try the following:to start with.
Idea 3:
Regarding the pages you could try to create a parent page with the
info
slug.—
This will not cover everything you mentioned, but hopefully this help you along the way.
Update:
Here’s something you could try to explore further (I’m not sure this even works):
You need to flush the rewrite rules, but you also need to modify the links trough the filters:
post_link
,term_link
,page_link
,tag_link
,date_link
, … etc.So you could try something like:
I guess there are better hooks available and just better ways to try?
This is just what comes first to mind, so please check and modify it 😉