1

I created a custom page template where I want to present some data specific for that page.

The file is placed in

wp-content/themes/themename/page-templates

In that file I want to include another php file from the parent directory. That file is placed in:

wp-content/themes/themename

So in the file i write:

<?php include('../Sorting.php');?>

But I receive an error saying the file doesn't exists.

Warning: include(../Sorting.php) [function.include]: failed to open stream: No such file or directory

I'm not that much into wordpress so I theorized that it was something to do with the include function but it works fine if I put the files in the same folder though.

0

You need to use get_template_directory(), this function will return local server path of you template and then you can use that path to access required file.

So in your case it would be something like below:

include get_template_directory() . "/Sorting.php";

PS: Mind the spelling of your file.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.