Support » Plugins » Using PHP inside a custom page

  • I have a php page which submits to itself. If there is no POST data, it displays a form which then allows you to input values. If you submitted data to it, it does some functions based on that data and outputs that. Right now it’s just plain text and pretty dull, and I wanted to include it as one of my WP pages. If I copy/paste the php and html inside a page, though, it prints out the form but the php is handled as regular text. Is there any way of including this form to make it fit in with the rest of my theme?

Viewing 4 replies - 1 through 4 (of 4 total)
  • of course..

    some ppl are going to ell you to go find a plugin that lets you use PHP within pages..

    I say meh.

    You have a page, lets call it myform.php

    Put myform.php in the root of your WP folder (where wp-config.php is)..

    At the top of myform.php, put this:


    You are then free to use ANY wordpress functions you like.. including

    get_header(); which will apply the header.php for your theme..

    get_sidebar(); which grabs your sidebar.php

    get_footer(); you guessed it — thats your themes footer.php

    Or make it a page template!

    I’d use the page template method if I wanted to make multiple pages which use the same set of PHP code to do something. For just one page, whoami’s method is probably sharpest.

    I ended up just copying page.php from my theme and grabbing the php form via the IFRAME tag. It took a little finagling (with the css property height) to get it to look right, but now it fits in great. Thanks everybody.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Using PHP inside a custom page’ is closed to new replies.