包括 header 和页脚到自定义位置
Including header and footer to a custom location
是否可以将 wordpress header 包含到位于文件夹中的 php 文件中,例如:wp-content/uploads/custom.php ?
您可以使用此文档:Integrating WordPress with your website
对于您的情况,您可以创建文件 content.php 并添加此代码,我刚刚在我的网站上尝试过并且有效:
<?php
$path = $_SERVER['DOCUMENT_ROOT']; // Gets the root directory URL
$path .= '/domain_dir'; // Appends your WordPress installation URL
require( dirname($path) . '/wp-blog-header.php'); // Require this to execute get_header();
get_header(); // Executes header.php
?>
是否可以将 wordpress header 包含到位于文件夹中的 php 文件中,例如:wp-content/uploads/custom.php ?
您可以使用此文档:Integrating WordPress with your website
对于您的情况,您可以创建文件 content.php 并添加此代码,我刚刚在我的网站上尝试过并且有效:
<?php
$path = $_SERVER['DOCUMENT_ROOT']; // Gets the root directory URL
$path .= '/domain_dir'; // Appends your WordPress installation URL
require( dirname($path) . '/wp-blog-header.php'); // Require this to execute get_header();
get_header(); // Executes header.php
?>