0

So, I have a snippet of code I'd like to tidy away in a directory that's close to the root my wordpress directory. Specifially it lives in /includes/inc.

I've created a file called test.php and within it it simply says echo "XXXX";

All I currenly want to be able to do is include this file in my functions.php file and see the sting printed to the screen.

The issue I'm seeing is that no matter what path I put into require, the page break. Even no path at all breaks the page. I'm 100% sure this is the correct path as well.

Why might this be happening?

Inside the functions.php file at the very top, below comments.

  require('/inc/test.php');

Inside the test.php file inside /inc within the theme folder:

 echo "TEST XXXXXX";

I've tried using * require_once * require * include (just does nothing) * include_once (same as include - does nothing)

  • What do you mean with "the page breaks"? – cybmeta Nov 24 '15 at 8:39
  • 2
    Your path is wrong. You say the file is at /includes/inc/ but you are trying to load /inc/test.php. The includes part of the path is missing. A bad path for require() will be a fatal error. – s_ha_dum Nov 24 '15 at 9:24
1

Try

require('inc/test.php'); 

instead of

require('/inc/test.php');

Remove / before inc.

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.