My front-page.php works fine in the WordPress root folder. But I would like to put it in the page-templates subfolder.

How do I make it load from there?

  • It's supposed to be in the root folder, why do you want it in the page templates subfolder? It isn't a page (or a page template)
    – Tom J Nowell
    Commented Feb 14, 2016 at 14:39

1 Answer 1


You can make use of the frontpage_template filter to adjust where your template should be loaded from

add_filter( 'frontpage_template', function ( $template )
    $locate_template = locate_template( 'page-templates/front-page.php' );

    if ( !$locate_template )
        return $template;

    return $locate_template;
  • it's not loading. I put the code in my functions.php. the path is correct, do I have to adjust anything else?
    – MrKainig
    Commented Feb 14, 2016 at 15:02
  • @MrKainig, you went in the backend(Admin) to Settings/Permalinks and clicked Save Changes ?
    – Charles
    Commented Feb 14, 2016 at 15:07
  • I just did that. Nothing changes
    – MrKainig
    Commented Feb 14, 2016 at 15:09
  • @MrKainig Had my filter name wrong, please see updated code Commented Feb 14, 2016 at 15:14
  • 1
    @Charles Lazyness, that is all. Closures are quicker to code and does not require that a unique function name. On stack like these, closures are easier to post and also avoid function name conflict. Closures do have one big set back though which you should always consider before using them, they cannot be removed with simple remove_action() and remove_filter() calls. Commented Feb 15, 2016 at 7:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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