WordPress.org

Ready to get started?Download WordPress

Forums

Custom Post Type UI
[resolved] Associate a page or post type with a template (6 posts)

  1. Fotoura
    Member
    Posted 5 months ago #

    Hi,

    Is there any way of associating a custom post type with a particular template.... custom post ui is fantastic - if I didn't have to also change the templates of every page I published too that would be amazing.

    Thanks!
    Rich

    http://wordpress.org/plugins/custom-post-type-ui/

  2. Michael Beckwith
    Member
    Plugin Author

    Posted 5 months ago #

    Well, there's no way that we can predict anything about your layout/theme and that's a very important thing. We can't by any means be sure that we wouldn't break your site's layout.

    If you check out http://codex.wordpress.org/images/1/18/Template_Hierarchy.png, you'll see that CPTs will use files like archives.php/single.php if you don't have a more specific file for the Post Types. If you don't have either of those, which you really should, it'll use index.php.

  3. Fotoura
    Member
    Posted 5 months ago #

    Thanks Michael,

    Don't get me wrong - I love this plugin! I've just recently been using a separate plugin (formidable) to publish 200 pages at a time and they are all using the default page template versus the fullwidth page I want them to have.

    Ideally I'd like to be able to say use single.$posttype.php and create a different template for my theme for each content type...

    Ok if that's not possible are you saying that I could specify a particular cpt to use say archives.php versus single.php for example - could I modify one of the other standard templates to be fullwidth i.e archives.php and tell the plugin to use that by default?

    Thanks again :)

    Rich

  4. Michael Beckwith
    Member
    Plugin Author

    Posted 5 months ago #

    archives.php is the default template file to show the posts listing, similar to index.php with your blog posts. They'll be shown in order by post date, newest to oldest. Unlike the "post" post type, it just uses archive.php first. Same idea with single.php, for single instances of posts in the post type. There won't be anything to tell the plugin, it'll just happen automatically.

    If you want different layouts for both the archive and the single view, you'll need to specify/create the single-$posttype.php and archive-$posttype.php files yourself. At that point, they'll be used first for your CPTs

  5. Fotoura
    Member
    Posted 5 months ago #

    Hi,

    I had no idea it was that simple. Is this mentioned somewhere in the plugin and I've missed it then apologies. If not, I really think you should make this obvious - it's such a great feature :). I've been wanting to do this for months but had no idea where to even start.

    Thanks for your response and again, thanks for a superb plugin!

    Rich

  6. Michael Beckwith
    Member
    Plugin Author

    Posted 5 months ago #

    I can add an enhancement issue on github to explain some of this more in the FAQ section.

Reply

You must log in to post.

About this Plugin

About this Topic

Tags