I am using
include 'filename.php' to load a php file into a template file, simply because the original PHP template file was getting huge and I wanted to split up the sections into different files for easy reference later.
Include works great until I try to use a function inside the included file, then it stops working. I searched around the web and it seems like since the included file is run on the remote server (is that right?) it does not pick up my function from functions.php as if it were running normally.
What is the correct way to do this? It seems I shouldn't use
include and maybe should be using something else?
Simplified code example:
<div id="section"> <?php include 'codesnippet.php'; ?> </div>
<ul> <li> <?php the_title(); ?> </li> </ul>
When any function is inside the included file, I get the error that the stream cannot be opened when trying to include it. The same type of error you would get if you mis-typed the filename in the include function.