繁体   English   中英

如何访问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.phpfooter.php文件。 我可以使用 include('') 访问 Project-2 和 Project-3 中的两个文件。

我的问题是,我必须使用 WordPress 根文件夹中的header.phpfooter.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');?>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM