WordPress.org

Ready to get started?Download WordPress

Forums

Custom Post Type UI
[resolved] Question: Do Custom Post Types Require Special Themes? (3 posts)

  1. starapple
    Member
    Posted 9 months ago #

    Hi there,

    Just a quick question as in the heading: do custom post types need a special theme to display their labels and content? That is, do I need to customize my theme to display whatever I create using Custom Post Type UI?

    Can a theme be made to be automatically aware of a custom post type?

    Thanks.
    Mark.

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

  2. Michael Beckwith
    Member
    Plugin Author

    Posted 9 months ago #

    By default, each theme will, or at least should, be able to display CPT archives/single posts. You should be able to see the archive at http://www.domain.com/CPT-SLUG/ where "CPT-SLUG" is the slug you chose. Unless you tailor your theme to have custom templates for the CPT, it'll fall back to archives.php to display the archive. If you don't have a template for that, it falls back to index.php. Same thing with single posts, single.php and then index.php

    http://codex.wordpress.org/Template_Hierarchy

    If you need to display them in custom locations or do custom things with them, then you'll need to use the WP_Query class to query for the posts in the post type, or if you're going a bit advanced, use the pre_get_posts hook to add them to already existing loops.

    http://codex.wordpress.org/Class_Reference/WP_Query

    http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts

    Hope that answers your questions, but feel free to ask more, I'll get to them when I can.

  3. starapple
    Member
    Posted 9 months ago #

    Thanks Michael. I don't think for the time being I need to do anything but have a post category that mimics (is parallel to) the standard blog post in various categories.

Reply

You must log in to post.

About this Plugin

About this Topic