0

The permalink setting in WP admin seems to only affect the "post" type, not the "page" type. The "page" will use the title as the url no matter what is set in the permalink setting.

I've searched and found some code that can change the permalink structure of "pages". For example, I tried the following code and it successfully put a page/ before the url:

add_action( 'init', 'custom_page_rules' );
function custom_page_rules() {
    global $wp_rewrite;
    $wp_rewrite->page_structure = $wp_rewrite->root . 'page/%pagename%';    
}

However, I tried changing %pagename% in the above code to %page_id% and it didn't work as expected. It literally set the url to %page_id%, not replacing it with the actual id. I tried %post_id% and the result is similar.

Your Answer

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

Browse other questions tagged or ask your own question.