Last active
July 26, 2022 17:25
-
-
Save wp-user-manager/1529d68519bb294faa848b3a19a85730 to your computer and use it in GitHub Desktop.
WP User Manager - Fix account/profile sub-page templates in WP 6.0+
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'template_include', function ( $template ) { | |
global $wp; | |
if ( ! isset( $wp->query_vars ) ) { | |
return $template; | |
} | |
if ( ! isset( $wp->query_vars['page_id'] ) ) { | |
return $template; | |
} | |
if ( $wp->query_vars['page_id'] === wpum_get_core_page_id( 'account' ) || $wp->query_vars['page_id'] === wpum_get_core_page_id( 'profile' ) ) { | |
$new_template_slug = get_page_template_slug( $wp->query_vars['page_id'] ); | |
if ( $new_template_slug && basename( $template ) !== $new_template_slug ) { | |
$template = dirname( $template ) . '/' . $new_template_slug; | |
} | |
} | |
return $template; | |
}, 100 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Save this file to your /wp-content/mu-plugins/ directory (you might need to create the mu-plugins directory).