• Hi all,
    I’ve got 3 different custom content types in my WordPress 3.1 site.
    For ease of management moving forward, I’d like to use the same page_type template for each custom content type.

    Obviously, I can create a post type specific template for each custom content type using the single-{post_type}.php

    But, what if I wanted to use the same template for each post type, how would I do that?

    Thanks!
    Troy

Viewing 3 replies - 1 through 3 (of 3 total)
  • According to the Codex:

    Single CPT template file: single-{posttype}.php
    Archive/Index CPT template file: archive-{posttype}.php

    So, if you’ve named your CPT “prefix_foobar”:

    Single CPT template file: single-prefix_foobar.php
    Archive/Index CPT template file: archive-prefix_foobar.php

    Thread Starter tpeterson

    (@tpeterson)

    Hi Chip,

    Yes, on a per-cpt basis, I can create the template file for them.
    But, if I want to use the same template for multiple cpt’s, that’s what I’m looking for…

    So cpt’s prefix_foobar1 & prefix_foobar2 both use single-prefix_foobar3.php as the template.

    I hope that makes more sense.

    Thanks!
    Troy

    The easiest thing to do might be to create “prefix_foobar.php” which contains your desired markup.

    Then, for each of your CPTs, create the appropriate template file, in which you simply call:

    get_template_part( 'prefix_foobar' );

    So, you’d still need to create each of the CPT template files, but you only have to maintain one single template file, that gets called by each one.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Multiple Custom Content Types – Same page template’ is closed to new replies.