Is there a way to have WordPress automatically create static pages from all of the template files in a given directory?

So rather than manually creating custom page templates in the WP dashboard, I'd like to write a script that looks at every file in a directory and creates a new custom page template for each one based on the template name given in the /* Template Name: Foo */ declaration.

I'm familiar with the solution offered here, but it still seems to require manually entering the pages one at a time.

  • 1
    I am not sure exactly what you want. You want WordPress to recognize the files as if they were custom page template files?
    – s_ha_dum
    Commented May 8, 2014 at 19:12
  • Yes exactly - I edited my question to hopefully make it more clear what I'm looking for.
    – cantera25
    Commented May 8, 2014 at 19:53
  • Under what circumstances do you need them to be recognized as such?
    – s_ha_dum
    Commented May 8, 2014 at 21:13
  • Do you still not understand what I'm asking or are you questioning the validity of what I'm trying to do?
    – cantera25
    Commented May 9, 2014 at 13:32
  • I understand what you are asking but I have not found a way to do it.
    – s_ha_dum
    Commented May 9, 2014 at 13:40


Your Answer

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

Browse other questions tagged or ask your own question.