Home > OS >  How to access the PHP file inside the WordPress theme?
How to access the PHP file inside the WordPress theme?

Time:10-12

I have a folder structure like below

Project-1
 .header.php
 .footer.php
Project-2
Project-3
wp-admin
wp-content
wp-includes
.
.
.
all WordPress files

Now, I have header.php and footer.php files in my Project-1 folder. I am able to access both files in Project-2 and Project-3 using include('').

My issue is, I have to use the header.php and footer.php files in the WordPress root folder. I added below code /wp-content/theme/themename/header.php

<?php include('https://test.com/Project-1/header.php');?>
<?php include('https://test.com/Project-1/footer.php');?>

But it's not working. Would you help me with this?

CodePudding user response:

You can Replace the URL with a local Path

Just do:

<?php include('/localpath/Project-1/header.php');?>

CodePudding user response:

You can Hardcode the Path like that

<?php include('/Project-1/header.php');?>

CodePudding user response:

Replace url with local path

# use ABSPATH defined by wordpress
<?php include(ABSPATH . '/Project-1/header.php');?>
# or hardcode the path 
<?php include('/localpath/Project-1/header.php');?>
  • Related