Support » Plugin: Custom Post Template » [Plugin: Custom Post Template] custom post types

  • Hey, so support for custom post types isn’t working for me. The plugin is working on standard posts though.

    I put this at the bottom on my functions.php file:

     * Hooks the WP cpt_post_types filter
     * @param array $post_types An array of post type names that the templates be used by
     * @return array The array of post type names that the templates be used by
    function my_cpt_post_types( $post_types ) {
        $post_types[] = 'Items';
        return $post_types;
    add_filter( 'cpt_post_types', 'my_cpt_post_types' );

    I have one custom post type, named Items.
    Is there some other code I need to put somewhere in addition to this?

    Also, in the Other Notes section on the plug-in’s page, it says “You can ALSO add this code to the functions.php file in your theme.” But it doesn’t say where it would be placed otherwise. Where does it go if you’re not putting it in functions.php?
    Sorry if this a dumb question, I’m new to this.

    Thanks in advance, I’m looking forward to utilizing this plug-in!

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Simon Wheatley


    Hi bphil00,

    Can you post the code you’re using to register your custom post type, please?

    sure, here it is:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    damn it, moderator!
    I’m at work now, I’ll repost using pastebin when I get home this evening. Sorry about that.

    Plugin Author Simon Wheatley


    It’s OK. I think the problem might be where you have register_post_type( 'Items', … WordPress is transforming to items (note lowercase).

    Accordingly, try changing your $post_types[] = 'Items'; to $post_types[] = 'items'; (again, note lowercase).

    Let me know how that is for you.

    Thank You!
    I’ll try it when I get home and update you.

    okay, I changed the uppercase ‘Items’ to ‘items’ and it worked! The meta box now shows up in the custom post editor. Unfortunately it’s not applying the template to the post’s page when viewing it.

    Here’s the code I used to register it:

    Any idea why it’s not applying the template?

    Actually, when I load that post it uses the 404 template.
    I’m at a loss here as to why this is happening.

    Well… damn, it’s a great idea for a plugin and definitely one that should be part of the wordpress core.
    Let me know if you get it functional, in the meantime, I guess I’m back to the drawing board.

    Anyone know of a plugin that adds custom templates to posts??

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘[Plugin: Custom Post Template] custom post types’ is closed to new replies.