Execute php in pages

If you have a page, and need to run PHP code that isn’t in your standard page template, you can:

  • Use a custom page template
  • Create a template with page-pagename.php
  • Implement and use a shortcode

All three are valid and suitable methods for doing this, however, do not:

  • Try to let users place actual PHP code in the post content ( MASSIVE security risk )

There are some other more esoteric options that would take longer to explain, and don’t involve a post ( of type page ). Those aren’t superior in any way other than that they require a greater knowledge of WordPress for the same result.