Support » Themes and Templates » Understanding templates in wordpress

  • Hi,

    This is probably something simple but I want to hear the experts and understand this well. Why is that if I create a new template for a custom theme in wordPress I need to make a comment and name it so WordPress can recognized as a template, but I don’t see this comment anywhere in the page.php, home.php, index.php, single.php etc.

    Is this because these are the default templates and wordpress already know those files?

    Thanks a lot!

Viewing 6 replies - 1 through 6 (of 6 total)
  • Lori

    (@bmonster99)

    You can see the comments on the Themes page in the admin area. They let WordPress know about the theme and display it on the themes list so you can activate it.

    Thank you for your reply!

    I’m talking about custom templates not themes.

    Lori

    (@bmonster99)

    Oh, I get it. You need this comment:

    <?php /* Template Name: YourTemplateName */ ?>

    Well I know exactly what I need to make it work I was just asking why is that the default templates don’t use this comment.

    Why is that if I create a new template for a custom theme in wordPress I need to make a comment and name it so WordPress can recognized as a template, but I don’t see this comment anywhere in the page.php, home.php, index.php, single.php etc.

    Sorry for the confusion

    Lori

    (@bmonster99)

    WordPress has page naming conventions that are the same across themes, including the pages you mentioned. Adding the comment makes your custom page template available as an option when you are writing a page through the WordPress admin interface. There are more ways to name pages that WordPress will know about without having to use the comment. You can see what they are and how they work here:
    http://codex.wordpress.org/Template_Hierarchy

    Thanks a lot for your comments.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Understanding templates in wordpress’ is closed to new replies.