I am using $wp_rewrite->non_wp_rules
I have the following code that works:
'name/(.*)' => 'index.php?post_type=post';
Im able to use a url like http://mysite.com/custom_name/post_name
using $wp_rewrite->non_wp_rules, how can I make pages work the same way.
This is just an example:
'anothername/(.*)' => 'index.php?post_type=page'; //for all pages
'anothername/(.*)' => 'page/pagename' //for one specific page
Is there a way I can have a page look like this:
http://mysite/custom_name/page_name.
The two examples above just redirects me to:
http://mysite/page_name //without the slug
I’ve not tried external rules, but you can achieve that with an internal rewrite and
pagename
:For parent/child pages you have to set
pagename
to the parent/child path,page/pagename
, or you can also usepage_id
and use the page’s ID.EDIT – note that you have to flush rewrite rules after adding new ones. a quick way to do this during testing is to visit the permalinks settings page.