1

I use front-page.php on my template to display home page. But I want to disable if the user uses another page for the home page from settings. Is there a solution? When user select a page from settings for home page, it not showed and front-page.php is loaded. I want to it disabled dynamically. Sorry for bad english.

2

Maybe template_include filter would get the job done for you. Something along these lines,

function prefix_another_front_page_template( $template ) {    
    if ( is_front_page() ) {
        $another_front_page_template = 'something.php'; // adjust as needed
        $new_template = locate_template( array( $another_front_page_template ) );
        if ( !empty( $new_template ) ) {
            return $new_template;
        }
    }    
    return $template;
}
add_filter( 'template_include', 'prefix_another_front_page_template', 99 );
0

Just don't use front-page.php then. As you can see in the template hierarchy if the user doesn't select a front page then home.php will be used. So you can use this for the front page if a user doesn't have a page set, and then if you don't include front-page.php in your template the theme will fall back to the default page template if they do select a page.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.