WordPress.org

Ready to get started?Download WordPress

Forums

Why are different parts of the page separated into different template files (7 posts)

  1. craigjross
    Member
    Posted 1 year ago #

    I am only very new to html and css and the way wordpress separates the header, the post and the footer into different php files both facinates and perplexes me. First, why do they do this and second, what file brings this all together into a single view on the front end.

  2. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

    Have a look at Theme Development.

  3. Usubba
    Member
    Posted 1 year ago #

    The main purpose of separating them is to make the structure flexible n easier if you don't differentiate them then on each page you'll have to provide the links for the header ,footer and the right/left panel if present for eg.if you want to change the name of a link in your header the changes will be available to all the pages if the header is differentiated or else the small change has to be done in all the pages .This is the idea behind creating separate templates .

    lastly it is included in index.php file like
    <?php include("header.php");?>
    <?php include("footer.php");?>

  4. craigjross
    Member
    Posted 1 year ago #

    @Usubba
    That is a great explanation. Thanks for taking the time to spell it out for me. Can the same approach be applied to straight up html/css sites that dont include php? the reason I ask is that I dont know php yet and would like to get familiar with this way of developing as I start to learn the php side of things.

    @esmi
    Thanks so much for the link. I will be having a long look at theme development. I think that I will learn a lot from reading this.

  5. craigjross
    Member
    Posted 1 year ago #

    I've been doing some homework and found SSI. Server Side Includes for html. Such as;
    <!--#include file="included.html" -->
    This stuff is so cool.

  6. Chip Bennett
    Theme Review Admin
    Posted 1 year ago #

    Don't use this:

    <?php include("header.php");?>
    <?php include("footer.php");?>

    Use get_header(), get_footer(), get_sidebar() for header.php, footer.php, and sidebar.php respectively. Use get_template_part() for including any other, arbitrary template-part file.

  7. craigjross
    Member
    Posted 1 year ago #

    Thanks, Chip.

Topic Closed

This topic has been closed to new replies.

About this Topic