As we know that WP has a feature called Page_Templates. But today, I got a question in my mind that can we add/use/access multiple page templates from single .php file (which is responsible to call page template.)

For example first 40 lines of demo-xyz.php will echo a "demo" page template and then after left lines echo a "xyz" template. then i want to select both as page template for different two pages in wordpress>pages>addnew>page attributes>select page template. (there both 1.demo & 2.xyz template name should be shown)

example (file:demo-xyz.php)-

Template : demo

....Codes For template demo

Template : xyz

.... Codes for template xyz

Reason - I have multiple page templates and i am finding me unable to manage too much template files that's why i wanna it's solution.

I searched everywhere for it but not find out a solution anywhere

  • No, this isn't possible. I misunderstood your previous version of this question and thought you meant the opposite. Frankly, this seems way harder to maintain. Commented Jul 7, 2021 at 14:23
  • thanks @JacobPeattie Now i have to use shortcode (which can be maintained in one file) to insert php into pages/posts..
    – user208353
    Commented Jul 7, 2021 at 14:29

1 Answer 1


This is not possible, a PHP file can only contain a single page template. There is no way to combine the files.

Your Answer

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