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

The file is placed in


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


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.

1 Answer 1


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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