• 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)
  • 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.

    Thread Starter fs_tigre

    (@fs_tigre)

    Thank you for your reply!

    I’m talking about custom templates not themes.

    Oh, I get it. You need this comment:

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

    Thread Starter fs_tigre

    (@fs_tigre)

    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

    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

    Thread Starter fs_tigre

    (@fs_tigre)

    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.