如何访问WordPress主题中的PHP文件?
How to access the PHP file inside the WordPress theme?
我的文件夹结构如下
Project-1
.header.php
.footer.php
Project-2
Project-3
wp-admin
wp-content
wp-includes
.
.
.
all WordPress files
现在,我的 Project-1 文件夹中有 header.php
和 footer.php
文件。我可以使用 include('').
访问 Project-2 和 Project-3 中的两个文件
我的问题是,我必须使用 WordPress 根文件夹中的 header.php
和 footer.php
文件。我添加了下面的代码 /wp-content/theme/themename/header.php
<?php include('https://test.com/Project-1/header.php');?>
<?php include('https://test.com/Project-1/footer.php');?>
但是没用。
将url替换为本地路径
# use ABSPATH defined by wordpress
<?php include(ABSPATH . '/Project-1/header.php');?>
# or hardcode the path
<?php include('/localpath/Project-1/header.php');?>
我的文件夹结构如下
Project-1
.header.php
.footer.php
Project-2
Project-3
wp-admin
wp-content
wp-includes
.
.
.
all WordPress files
现在,我的 Project-1 文件夹中有 header.php
和 footer.php
文件。我可以使用 include('').
我的问题是,我必须使用 WordPress 根文件夹中的 header.php
和 footer.php
文件。我添加了下面的代码 /wp-content/theme/themename/header.php
<?php include('https://test.com/Project-1/header.php');?>
<?php include('https://test.com/Project-1/footer.php');?>
但是没用。
将url替换为本地路径
# use ABSPATH defined by wordpress
<?php include(ABSPATH . '/Project-1/header.php');?>
# or hardcode the path
<?php include('/localpath/Project-1/header.php');?>