treehouse : what would you like to learn today?
Web Design Web Development iOS Development

PHP functions in word press

  • I am setting up a basic php framework to use as a basic starter for the websites I do. Mostly to have the same place to start from but I want to learn more about PHP then I do. The best way for me is doing.


    I had a question about how Wordpress had it's functions available to any page and there isn't an includes(); function at the beginning of the pages.

    I have my index.php set up as this calling the functions for to include different functions on the page:

    <?php include('functions.php');?>

    <?php get_header();?>

    <?php get_content();?>


    <?php get_sidebar();?>


    <?php get_footer();?>


    I notice that in WordPress there is never a need to do the first includes(); function. How are all the functions available without that. Probably a very newbie question but I'd like to get my head around it.
  • Look in wp-includes/functions.php file - the get_header(), get_footer(), etc. functions all utilize include() (or require/require_once() - I can't remember).
  • When you browse to a wordpress site it calls the root index.php which in turn requires and includes all the functionality that wordpress uses and then calls the index.php file in the active template.

    I was just working in the template and I thought there might be another way I was able to access the WP functions. As I didn't see any include() or require() bringing in function libraries. Until I looked beyond the template and to how the template index.php files was called.

    "john010117" said:
    Look in wp-includes/functions.php file - the get_header(), get_footer(), etc. functions all utilize include() (or require/require_once() - I can't remember).


    I think that file is general-template.php

    Thanks for the reply.