tags:

views:

40

answers:

2

Hi,

I have a simple HTML form that posts to a PHP page, which will then return the user some content. I want to take this PHP code and get my wordpress theme to wrap around it, so that appears like a normal page on my site. Can't find any resources on this - where do I begin?

Thanks.

+3  A: 

You can create a new page template by uploading a php file which starts with the following:

 
<?php
/*
Template Name: Something
*/
?>

Then create a new page in Wordpress, and look in the dropdown box for Template on the right (depending on what version you are using). Select that, and that newly created page can now have whatever php code in it you want. You'll probably want to copy the default page template (if one exists) as a starting point.

See http://codex.wordpress.org/Pages for more detail.
+1  A: 

Find out the post ID / page ID of where you want your custom PHP code to go.

Assuming that where your custom code will go is in a post, you should create a file in your theme's folder called single-POSTID.php.

Assuming that where your custom code will go is in a page, you should create a file in your theme's folder called page-PAGEID.php.

Copy the base code from single.php or page.php into the newly created file, and you can insert your custom code in the new files. Form actions should usually be "#" and if your form isn't working appropriately, it's most likely because of one of your HTML form fields are used by Wordpress to do something. (e.g. a textbox with the name of "comment" will not properly work under your code, since Wordpress will think you're trying to add a comment).

If you do anything that requires database access, Wordpress keeps the DB connection alive in your theme, so you don't need to connect to the database again. Unless of course, whatever you're trying to do is in a separate database other then the one Wordpress is installed in.

Let me know if that helped you or if you have more questions!

Raphael Caixeta