简体   繁体   中英

Add PHP Pages to wordpress

I have a HTML form that user can interact with and insert the data to a database. ( One HTML form and about 3 pages .php ) I need to implement this form to a word press page. I created a page in wordpress and it gives me a blank area to write my content but i don't know where i put my files. so appreciate your support to help me , thanks .

Where you place your files depends greatly on the structure of your wordpress template. If you want to make a page that can be accessed via a url like "www.yourdomain.com/form", then you can make a "Page" in Wordpress (via the "Page" panel via the dashboard), and name it "Form" and then, in your form's HTML (or PHP) file, set your HTML up as a template using this syntax:

Put this at the very top of your PHP page that contains your form's HTML/PHP:

<?php
/*
Template Name: My Form Page
*/

The code comment above is something wordpress will look for exclusively, and tells the wordpress engine that this page (your form HTML) is now a template named 'My Form Page'. So now, in the Wordpress Page editor for your "Form" page, you can attach your new template to your newly-created "Form" page by selecting "My Form Page" from the Template Dropdown in the Page editor.

Here is a screenshot of what the "Template Dropdown" looks like (per the Wordpress documentation):

以下是“模板下拉列表”的屏幕截图:

After you follow these steps, navigating to this page will reveal your form's HTML, instead of a blank page.

You should refer to the Wordpress documentation on Page Templates for more information:

Hope this helps!

There are a few ways to add custom behaviour to a WordPress installation. Either per Addon/Plugin or Template Logic or custom modifications. I would recommend that you read through the wordpress developer guidelines and write your php files as plugin.

After that hook your plugin to your desired destinations and do your whished actions.

See this link for writing your plugin: wordpress codex

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM