I've made a custom author template model.php for a custom role model (Ultimate members Plugin) and I have the default author.php also. I want to assign model.php to model when someone goes to model a single page by keeping the admin.php the same for admin. I used this code.

add_filter( "template_include", "abc" );

function abc( $template_path ) {
    if ( is_author() ) {
        $author = get_user_by( "slug", get_query_var( "author_name" ) );
        $role = $author->roles[0];
        if ( "um_model" === $role ) {
            $template_path = locate_template( array ( "model.php" ) );
        return $template_path;

This code is working as per my need by all the other pages of my website become a blank (white screen).

Can someone help me with this?

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.