WordPress.org

Ready to get started?Download WordPress

Forums

Understanding templates in wordpress (7 posts)

  1. fs_tigre
    Member
    Posted 3 years ago #

    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!

  2. L B
    Member
    Posted 3 years ago #

    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.

  3. fs_tigre
    Member
    Posted 3 years ago #

    Thank you for your reply!

    I'm talking about custom templates not themes.

  4. L B
    Member
    Posted 3 years ago #

    Oh, I get it. You need this comment:

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

  5. fs_tigre
    Member
    Posted 3 years ago #

    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

  6. L B
    Member
    Posted 3 years ago #

    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

  7. fs_tigre
    Member
    Posted 3 years ago #

    Thanks a lot for your comments.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.