WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have 3 theme files: header.php, navigation.php and page.php

page.php calls header.php They both have content which is added to via a custom box.

navigation.php has some content added to it via a custom box. Based on the page being called, I would want to include navigation.php within header.php as well.

How would I do this?

I want navigation.php to be included into page.php while both have content that is added to it via a custom box.

My guess Create a page called 'Navigation', for example. I never display this link in my templates so that it's not used as a page on it's own even though it exists as one. This will allow me to edit its contents.

Create another page by whatever name, this would use page.php. page.php would use some function to include navigation.php based on is_home().

If that idea is right, can someone please elaborate and give me details on what functions I would use, etc?

share|improve this question
up vote 1 down vote accepted

You can include any template you want using get_template_part()


<?php get_template_part('navigation'); ?>

Using this function also gives you child/parent theme support.

Also of note, you could put:

<?php get_template_part('navigation','search'); ?>

Which would attempt to load navigation-search.php, but if that isn't found or doesn't exist, it will fallback and load navigation.php instead.

I use this in my personal code to make loading different excerpts for different post types easier, e.g.:


It will load excerpt.php by default, but I could override it for any post type I wish e.g. excerpt-page.php

As a sidenote, use this function only for template files, do not use it as a general purpose include statement, e.g. it would be a bad idea to load a PHP library or a configuration file this way.

share|improve this answer
Perfect. Thanks a lot. That really helped :) – Housni Apr 17 '12 at 14:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.