• Resolved totalnoob

    (@totalnoob)


    Hello,
    What are the functionalities of single.php? Will everything inside the index.php’s loop become deactivated if I create a single.php file? Thanks in advance.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    No, the index.php will still be used, but the single.php will take its place for single post pages.

    Read more on this subject here:
    http://codex.wordpress.org/Template_Hierarchy

    Thread Starter totalnoob

    (@totalnoob)

    WordPress looks for template files with specific names in the current Theme’s directory and uses the first matching template file listed under the appropriate query section below.

    Doesn’t this mean that the ‘first matching template’ replaces all the other ones?

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Yes, but only for that specific case.

    Look at the hierarchy. A single.php file is only used for single-post pages. Not for root pages, or archive pages, or category pages…

    See here for graphical example:
    http://codex.wordpress.org/images/1/1d/wp_Template_Hierarchy.png

    Thread Starter totalnoob

    (@totalnoob)

    Ok, so single.php will be used(inplace of index.php) when the page contains only a single post. Otherwise, index.php will be used. Am I getting it now?

    Ok, so single.php will be used(inplace of index.php) when the page contains only a single post. Otherwise, index.php will be used.

    If you don’t have a single.php file in your theme folder – WP will use index.php to display the single post view, too.

    For all the other views (monthly or category archives, Pages, search etc.) WP looks for the template files exactly as it is described in the Codex article for each case.

    Index.php is the general “fall back” in case there is no specific template for the case.

    Thread Starter totalnoob

    (@totalnoob)

    Thanks. I think I understand now

    Ah.. I’m glad I found this post. Makes sense now.

    My problem is that I have multiple posts showing up on my single.php. What am I missing?

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘How does single.php work?’ is closed to new replies.