作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在 WordPress 中创建自定义表单。表单的第1步是HTML代码,它收集数据并通过post方法将其发送到PHP文件,然后将其写入MySQL数据库并使用PHP代码创建表单的第2步。我的问题是,我想在步骤 1 中 WordPress 使用的表单的步骤 2 中包含默认的 WordPress 页眉和页脚。有没有办法通过在我的 PHP 脚本中包含 header.php 和 footer.php 的代码来实现此目的?
最佳答案
你是说这个吗?
<?php get_header(); ?>
对于页脚:
<?php get_footer(); ?>
如果您看一下 get_header() 函数
:
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]
关于php - 将 WordPress 页眉和页脚添加到 PHP 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39877079/
我是一名优秀的程序员,十分优秀!