I have a client who is adamant that the permalink structure for pages must be along the lines of postname/postid
, such as test-page/7
.
I've gotten as far as adding the post name using $wp_rewrite->page_structure
with the following code, which works fine.
add_action( 'init', 'custom_page_rules' );
function custom_page_rules() {
global $wp_rewrite;
$wp_rewrite->page_structure = $wp_rewrite->root . '%pagename%';
}
However, when I add %post_id%
, it is not converted to the page's ID. Examination of the WP_Rewrite class reveals that there is no %page_id%
placeholder. Is this possible to do and, if so, how can I achieve it?