Skip to main content
CSS-Tricks
  • Articles
  • Videos
  • Almanac
  • Newsletter
  • Guides
  • DigitalOcean
  • DO Community
Search
Code Snippets → WordPress → Include Any File From Your Theme

Include Any File From Your Theme

Avatar of Chris Coyier
Chris Coyier on Aug 6, 2009
<?php include (TEMPLATEPATH . '/your-file.php'); ?>
Psst! Create a DigitalOcean account and get $200 in free credit for cloud-based hosting and services.

Comments

  1. Guy Haines
    Permalink to comment# March 22, 2011

    Thanks Dude.

    Reply
  2. stefan zimmermann
    Permalink to comment# July 26, 2011

    awesome site for someone who hates learning to suck

    Reply
  3. Christopher Geary
    Permalink to comment# March 25, 2013

    If your trying to include another file in (.php file) for your theme, then use get_template_part(), which looks like:

    <?php get\_template\_part( 'content' ); ?>

    It has an optional second paramater too which you can use to include something like: content-post.php by using:

    <?php get\_template\_part( 'content', 'post' ); ?>

    Read More:
    http://codex.wordpress.org/Function_Reference/get_template_part

    Reply
    • Christopher Geary
      Permalink to comment# March 25, 2013

      You don’t need the backslashes, the “comment preview” didn’t like my underscores unless they had backslashes, and now its screwed up the actual comment.. -.-

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

CSS-Tricks is powered by DigitalOcean.

Keep up to date on web dev

with our hand-crafted newsletter

DigitalOcean
  • DigitalOcean
  • DigitalOcean Community
  • About DigitalOcean
  • Legal
  • Free Credit Offer
CSS-Tricks
  • Email
  • Guest Writing
  • Book
  • Advertising
Follow
  • Mastodon
  • Twitter
  • Instagram
  • YouTube
  • CodePen
  • iTunes
  • RSS
Back to Top