[英]Adding WordPress header and footer to a PHP script
我正在嘗試在WordPress中創建自定義表單。 表單的第1步是HTML代碼,該數據收集數據並通過post方法將其發送到PHP文件,然后將其寫入MySQL數據庫並使用PHP代碼創建表單的第2步。 我的問題是我想在WordPress在步驟1中使用的表單的步驟2中包含默認的WordPress標頭和頁腳。是否可以通過在我的PHP腳本中包含header.php和footer.php的代碼來做到這一點? ?
你是這個意思?
<?php get_header(); ?>
對於頁腳:
<?php get_footer(); ?>
如果您看一下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 );
}
您的根主題上至少有一個header.php文件嗎?
常見的Wordpress結構:
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]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.