WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] clarification about template hierarchy (5 posts)

  1. antr
    Member
    Posted 4 years ago #

    I do not understand the template hierarchy explained in:
    http://codex.wordpress.org/Template_Hierarchy
    and represented in
    http://codex.wordpress.org/File:Template_Hierarchy.png
    Which is the order conditions are tested to choose the template? From top to bottom in the figure?
    So, first condition is: is_home, then is_404, and so on? Or there is another one?

  2. Pete
    Member
    Posted 4 years ago #

    If you have a home.php file that will be the first that appears, unless you nominate a specific page in the settings

    If you don't have a home page then the index.php file will be the first that appears...

    If you have a 404 error (like a wrong typo) then the 404.php will appear first... if no 404.php then the index.php will appear.

    In essence the index.php is the last resort fall back if the 'higher' xyz.php isn't present.

  3. antr
    Member
    Posted 4 years ago #

    I have /understood/ the flow chart in horizontal way.
    But in my opinion the /vertical/ way is /not/ clear.
    You have not answered to my doubt.
    Which is the order conditions are tested?
    1) is_home
    2) is_404
    3) is_search
    4) and so on
    or another one?

  4. MichaelH
    Member
    Posted 4 years ago #

    In 2.9.2 look at wp-includes/template-loader.php for that.

  5. antr
    Member
    Posted 4 years ago #

    Perfect, thank you.

Topic Closed

This topic has been closed to new replies.

About this Topic