Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress PHP for WordPress PHP Basics for WordPress The Loop

Shane Cutts
Shane Cutts
15,107 Points

Why does the template file name need to be broken up? ie. ( 'content', 'none' );

When using a PHP function like "get_template_part", why does the template file name need to be broken up? ie. ( 'content', 'none' );

1 Answer

Jeremy Castanza
Jeremy Castanza
12,081 Points

Those are parameters for the get_template_part function. The first one is required (slug) and the second is an optional (name) parameter. It basically has to do with how customized your code is and I believe it's also related to child theme development.

The whole idea with the get_template_part function goes back to a concept in programming called "DRY" - "Don't Repeat Yourself." The idea behind this aspect of Wordpress is that your code is only written one time in one place, which makes updates to code a lot easier to manage. It also keep your code trim, which improves performance.

I recommend referencing the Codex too for some other helpful info. https://codex.wordpress.org/Function_Reference/get_template_part