WordPress has a built-in template hierarchy that determines what template file will be loaded for a given type of post or page. If you have a look at the visual overview of the hierarchy, you’ll find that custom posts have their own specific entries. For example, if your custom post type is named book
, then a single post’s template will be single-book.php
if it exists, single.php
if it does not. (index.php
is the global fallback — a theme really only needs to contain style.css
and index.php
to function.)
Any desired template files (ie, single-{$posttype}.php
) should be added to your active theme.