I am trying to create a custom form in WordPress. Step 1 of the form is HTML code that collects data and sends it to a PHP file through the post method, then writes it to the MySQL database and creates Step 2 of the form using PHP code. My problem is that I want to include the default WordPress header and footer in Step 2 of the form that WordPress uses in Step 1. Is there a way to do this by including the code of header.php and footer.php in my PHP script?
Asked
Active
Viewed 2,645 times
1 Answers
1
You mean this?
<?php get_header(); ?>
And for the footer:
<?php get_footer(); ?>
If you take a look at the get_header() function
:
function get_header( $name = null ) {
/**
* Fires before the header template file is loaded.
*
* The hook allows a specific header template file to be used in place of the
* default header template file. If your file is called header-new.php,
* you would specify the filename in the hook as get_header( 'new' ).
*
* @since 2.1.0
* @since 2.8.0 $name parameter added.
*
* @param string $name Name of the specific header file to use.
*/
do_action( 'get_header', $name );
$templates = array();
$name = (string) $name;
if ( '' !== $name ) {
$templates[] = "header-{$name}.php";
}
$templates[] = 'header.php';
locate_template( $templates, true );
}
Do you have at least a header.php file on your root theme?
A common Wordpress structure:
your_project_folder
-wp-admin
-wp-content
-languages
-plugins
-themes
-YOUR_THEME_FOLDER
-[HERE YOU PLACE YOUR index.php file and header.php for example, and inside index.php you place your get_header() function]
-upgrade
-uploads
-wp-includes
index.php
wp-activate.php
wp-blog-header.php
wp-comments-post.php
wp-config.php
wp-cron.php
[...more files]

Slico
- 436
- 2
- 16
You stated that you are $age years old and $supplement_user use supplements.
"; ?> – Stephen Rose Oct 05 '16 at 15:59