Using custom functions without including them

I noticed that I can create a blank file in my WordPress theme,
and use a function I’ve created in functions.php without including anything.

How is this possible?

Read More

My function in functions.php (

    function getContentFromID($int) {

        $my_id = $int;
        $my_id = get_post($my_id);
        $content = $my_id->post_content;
        $content = apply_filters('the_content', $content);
        $content = str_replace(']]>', ']]>', $content);
        echo $content;
}

ONLY content in test.php (and it gets the correct content if i replace $scrapeID with e.g. 135)

<?php getContentFromID($scrapeID); ?>

Related posts

Leave a Reply

4 comments

  1. Something else has already included functions.php before test.php has been included. PHP puts everything in a single global scope unless you tell it otherwise somehow.

  2. Because your new file is included by some other file, and this file which includes your file also includes the functions file, so the functions are visible to your file.