Using A Page Template File For Single Custom Post Types

If for some reason you don’t want to use a default single post template for your custom post type, you can use a page.php file instead.

On top of this you can also add support for Page Attributes to the code in your functions file which registers your CPT.

The downside of copying your parent themes page.php file to your child theme and renaming it single-cpt.php, is you may lose pagination.

Single CPT Page File

For themes which include get_template_part(), you can simply use this code in your single-cpt.php file rather than all the standard code included in a page.php file.

get_template_part( 'page' );

Pretty cool when you only have one line of code in a template. Just one of the many benefits of using get_template_part() for coding/resource efficiency.

Add Page Attributes To Custom Post Types

This is the line of code you can add to the code you use in your functions file to register your custom post type.

'supports' => array(  'page-attributes' ),

Standard stuff in Genesis but many non Genesis users don’t add this to their code for some reason maybe because they simply don’t know about it.

Add Pagination To Single Custom Post Types

If you need to add pagination to a your single cpt’s, this code may help depending on which theme you’re using.

My opinion is to use a single post file for this as you can easily add page attributes anyway and retain built in pagination.

2 responses to “Using A Page Template File For Single Custom Post Types”

  1. Herb Trevathan Avatar
    Herb Trevathan

    Awesome! Thank You : )

    1. Brad Dalton Avatar
      Brad Dalton

      No worries Herb

      Not sure why a page template is better than a single post template for this purpose but i guess there must be a reason as posts always seem more flexible than pages and you can add page attributes anyways.

Was This Tutorial Helpful?

Free

$0

Access only to all free tutorials per month.



Monthly

$75

Access to 10 premium tutorials per month.


Tutorial Request


Includes code guarantee and coding support.

Yearly

$500

Access to 15 premium tutorials per month.


Monthly Tutorial Request


Includes code guarantee and priority coding support.