/** * Custom Parent URL Structure * Parent slug: /bc/ */ function custom_bc_page_parents( $post_link, $post ) { if ( $post->post_type !== 'page' ) { return $post_link; } // Pages that should use /bc/ as parent $bc_pages = array( 'https://www.getproclean.com/kitsilano/', 'service-2', 'service-3', 'about-us', 'contact-us', ); // Check if current page is in the list if ( in_array( $post->post_name, $bc_pages, true ) ) { $post_link = home_url( '/bc/' . $post->post_name . '/' ); } return $post_link; } add_filter( 'page_link', 'custom_bc_page_parents', 10, 2 ); /** * Make WordPress recognize /bc/page-slug/ URLs */ function custom_bc_rewrite_rules() { $bc_pages = array( 'https://www.getproclean.com/kitsilano/', 'service-2', 'service-3', 'about-us', 'contact-us', ); foreach ( $bc_pages as $page_slug ) { add_rewrite_rule( '^bc/' . $page_slug . '/?$', 'index.php?pagename=' . $page_slug, 'top' ); } } add_action( 'init', 'custom_bc_rewrite_rules' );