Community Forums › Forums › Archived Forums › General Discussion › Difference in page template naming?
- This topic has 3 replies, 2 voices, and was last updated 11 years ago by David Chu.
-
AuthorPosts
-
March 8, 2013 at 12:22 pm #25024jjeatonMember
Hey, this is probably a stupid question, but what is the difference between page templates named like this:
page-contact.php (as mentioned here: http://codex.wordpress.org/Template_Hierarchy)
and
page_landing.php (as I see in many child themes)
Does it not matter whether you use a dash or underscore, or is the underscore Genesis-specific?
March 9, 2013 at 7:56 pm #25239David ChuParticipantNot a stupid question at all! One needs to be a serious WP theme geek to know that. Generally this sort of thing has to do with Custom Post Types. And that's not specific to Genesis, but to WordPress. Here are typical WP template files:
page.php - for displaying static Pages.
single.php - for displaying single Posts.If I have a custom post type called "product", I might want a special template for displaying them.
So if I want a static Page that shows the product(s), I would name it page-product.php. If I wanted a single Post page (terminology gets gnarly!), then I would name the template single-product.php. Then you need to code the logic in the template to display all that.
I hope that helps.
Dave
Dave Chu · Custom WordPress Developer – likes collaborating with Designers
March 9, 2013 at 10:06 pm #25253jjeatonMemberHey Dave, Thanks for the response, however that wasn't what I was asking about.
I'm quite familiar with the Template Hierarchy, it's that I've never seen templates using underscores (_) instead of dashes. And so I was wondering if that was Genesis-specific or WordPress just doesn't care if it's a dash or underscore.
Examples:
archive-projects.php vs archive_projects.php
single-project.php vs. single_project.php
Many of the child themes include a "page_landing.php" which is what prompted the question, I'm wondering whether it has to be that or it can be "page-landing.php"
Thanks.
March 10, 2013 at 9:28 am #25308David ChuParticipantOh, good point, I didn't want to presume, but I underestimated you.
I'm pretty sure you can use either underscores or hyphens. I know that when I make custom post type templates, I've used hyphens, but lots of template files have underscores. I'm also pretty sure this has nothing to do with Genesis - they would get in big trouble if they started doing something that "violated" normal WordPress procedure - all kinds of things would break, IMO.
Maybe someone else would know the exact rule. I'm not a guy who reads the "standards manuals" much, and my custom themes generally only have 2 files, functions.php and style.css. Thanks to Genesis, I can pack almost anything I need into that one function file if I want to. Of course, I work with some wild non-Genesis themes that have zillions of template and other files.
One thing that was funny to me was being asked to modify a theme that was built on Genesis, but had many, many files - they clearly didn't use any Genesis functionality at all, they just had Genesis running, but went totally old-school on the theme's development. 🙂
Dave
Dave Chu · Custom WordPress Developer – likes collaborating with Designers
-
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.