I want to use .php extension for php that have a logic like functions.php, and for a html template file .phtml.

Is there way to use .phtml instead of .php extension? For example, sidepar.phtml, page.phtml and so on.

3 Answers 3


I'm going to echo all of the above comments & say it's not a good practice to get into. You might want to borrow a convention from the PHPTemplate library used in Drupal and call your files something.tpl.php. That way it's still a .php file, but you have an extra extension showing it's a template.


No, there is no such ability. Even more I wouldn't recommend you to use .phtml extensions. Why? Because they won't be interpreted as PHP files if you open them directly in the browser (for instance http://mysite.com/wp-content/theme/mytheme/single.phtml).

So the best practice and good habit is to use .php extension for your templates.

  • 2
    As far as I know, interpretation of file depends on server setting that I can change myself. But if it is good practice to use .php in wordpress community, I'd use .php extension. Thanks for your reply.
    – ironsand
    Commented Oct 2, 2013 at 9:22
  • 1
    Yes, it is OK if you do it for yourself. But if you will share your theme, then you can't be confident in other people hosting environments. Commented Oct 2, 2013 at 9:43
  • I'd even go further, @EugeneManuilov I dont think it is a good practice within WordPress development. Because you start doing it for private use code and soon enough you will be coding for a customer or contributing to a project with these acquired routine, that doesn't fit the community best practices for WP :)
    – versvs
    Commented Oct 2, 2013 at 16:17

You can achieve this with .htaccess files by adding the line

AddHandler php-cgi .phtml

File Handling is actually done by your server and not php itself, so yes you can change the extensions to something custom.

However as stated in a comment. I would only do this if you are not going to share your themes as most people wouldn't be able to use it.

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.