Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


Sirin Srikier
Sirin Srikier
7,671 Points

How do I add a row in the default page template?

I am trying to put a form and background image in a row on all the pages so I can add them as html tags on the default page template but how can I do this in a cleaner way? I'm thinking adding this into a php file and include it on the default template but how do I do it?

1 Answer

Sue Dough
Sue Dough
35,800 Points

In programming you want to keep your code DRY. ( DO NOT REPEAT YOURSELF )

Since you mentioned this going on "all the pages" then you could use the get_template_part WordPress function.

First create a folder in your theme called "content". Then you can add the following file:


with the following code:

<div class="row">
  <form class="" action="index.html" method="post"></form>
  <?php _e( 'hello world', 'test' ); ?>

Then in your templates simply just put:

<?php get_template_part( 'content/content', 'test' ); ?>

This way you write 1 piece of code and can include it wherever in your theme many times as you want.

Alternatively if you use the Header or Footer you can include something on every page however that may not be ideal so get_template_part comes in very handy for this sort of stuff.