The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End PHP Includes

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #35306

    Warning: My knowledge of PHP is limited at best!

    I’ve recently decided to change from the blank WordPress theme of Starkers to HTML5 Reset (For WordPress).

    I did this with the intentions of learning WordPress from the ground up. I found that Starkers still had a lot of things implemented that i didn’t need/understand.

    Straight off the bat i’m a little confused as to what PHP Includes actually achieve and what i should be using them for. This theme has to two ‘incs’, meta.php & nav.php. Within say the index.php file they will be called using .

    My question is, what is the difference between just inserting the contents of nav.php straight into the index.php, instead of including it?

    Also, what is the different between using includes and say, inserting a sidebar into a template by using ?


    The main difference with why this is done in WordPress and other CMS’s is because it only requires you to declare the code once and just include it anywhere you need it, if you needed to update the code you would have to go back and edit every single file which would be time consuming.

    The function get_sidebar(); can only be called within the WordPress template as it’s a global function which is specific to the WordPress core and not the theme.


    As SgtLegend already said you don’t normally use include() in WordPress theming.
    Normally understanding the WordPress templates hierarchy is not particularly straight forward, possibly this link could clear things up a little bit.

    On top of it there are some other hints that lets you load portions of templates based on certain conditions, there are different ways to do that based on what you need to do, this page from the official documentation should help you through it:

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Back End’ is closed to new topics and replies.