ThemeShaper Forums » Thematic

[closed]

Any WP 3 Custom Post Types Pioneers Out There?

(11 posts)
  • Started 3 years ago by nimrod
  • Latest reply from Danieliser
  • This topic is not resolved
  1. nimrod
    Member

    BLEH
    I must admit that I've been disappointed in Custom Post Types (CPTs). There was so much talk prior to v3.0 release of the coming revolution of WordPress as "CMS" and now it seems like crickets.

    CPTs and THEMATIC
    I'm wondering if anyone has success stories using Thematic and child themes with CPTs...?

    CUSTOM TEMPLATES
    From what I gather, CPTs only seem to display via custom template .php files. This seems like a step backward and a messy requirement causing me to litter my child theme with multiple template files and redundant code within each.

    FUNCTIONS.PHP
    Is it possible or desirable to create CPT page displays via functions.php in the child?
    _________

    BASIC USE
    My needs seem simple: I just want to create CPTs with clearly labeled custom fields (or taxonomies?) in the way I've done using More Fields plugin.

    CLIENTS' EASE
    This way a client can write up a Book post and, in addition to regular content, enter custom info in each post about things like pages numbers and publisher and date via clearly labeled custom fields (and NOT the generic fields all piled up in the usual WordPress custom fields block).

    DISPLAY
    Then I want to display that custom content on a page with ascending, descending, or alphabetical, etc. sorted titles and excerpts with specially styled custom fields, both in the excerpt list page and the single full content page.

    LIKE CATEGORIES
    It's really not that different from how I can create a category and then make a nav menu item that displays just posts from that category.

    EXTRA
    Extra points for being able to automatically show thumbnails left aligned to excerpts and so on like any magazine template.
    _________

    YEARNING
    Sorry, I'm rambling in yearning for simple and effective use of CPTs!

    BEEN THERE
    I know about the known post from Tadlock, but I'm not getting it: http://justintadlock.com/archives/2010/04/29/custom-post-types-in-wordpress

    Here's a very thorough and clear taxonomies explanation with examples article:
    http://net.tutsplus.com/tutorials/wordpress/introducing-wordpress-3-custom-taxonomies/

    Posted 3 years ago #
  2. i have only dabbled in them so far. ahd while it is not a child theme, Devin just released a super awesome looking html5 theme that uses custom post types for portfolio pages. worth checking out if you havent already:

    http://wptheming.com/2010/07/portfolio-theme/

    i believe he is only adding 2 extra files to accommodate the custom post types... a single version and an index version.

    Posted 3 years ago #
  3. Jawillde
    Member

    I've been pretty successful getting custom post types to work using a child theme. It's really easier than you think. You don't need to create a new post template for each custom post type unless you want to change the layout of the post.

    Your desires are much more complicated than what I'm doing but it shouldn't be too difficult to do all of it.

    You register your custom post type using your child theme's functions.php with the labels you want and it will automatically use the standard single.php unless you define a single-custom.php ("custom" should be replaced with the name of you custom post type) file and then it will automatically use that one.

    You'll need to list what you want to display on the custom post's edit screen. What it supports are already built into Wordpress. Anything beyond that would be done with taxonomies. Custom taxonomies are out of my league but after looking at that article you posted, it looks to be about as simple as registering a custom post type. The only difference is you are registering extra fields that Wordpress doesn't use out of the box.

    You really need to work through the entire article (http://justintadlock.com/archives/2010/04/29/custom-post-types-in-wordpress) to get the hang of custom post types and then work on the custom taxonomies. I just skipped stuff that didn't apply to my needs.

    Here's what is in my functions.php file:

    // Creating a story post type
    add_action( 'init', 'create_my_post_types' );

    function create_my_post_types() {
    register_post_type( 'istory',
    array(
    '_builtin' => false, // It's a custom post type, not built in!
    'capability_type' => 'post',
    'labels' => array(
    'name' => __( 'iStories' ),
    'singular_name' => __( 'istory' ),
    'add_new' => __( 'Add New' ),
    'add_new_item' => __( 'Add New istory' ),
    'edit' => __( 'Edit' ),
    'edit_item' => __( 'Edit istory' ),
    'new_item' => __( 'New istory' ),
    'view' => __( 'View istory' ),
    'view_item' => __( 'View istory' ),
    'search_items' => __( 'Search iStories' ),
    'not_found' => __( 'No istories found' ),
    'not_found_in_trash' => __( 'No istories found in Trash' ),
    'parent' => __( 'Parent iStories' ),
    ),

    'public' => true,
    'show_ui' => true,
    'publicly_queryable' => true,
    'exclude_from_search' => false,
    'supports' => array( 'title', 'custom-fields', 'editor', 'thumbnail', 'comments' ),
    'taxonomies' => array('post_tag', 'category'),
    )
    );
    }

    The above just registers a new post type that uses existing fields and taxonomies that WP supports out of the box but I'm limiting the editor to only show what I need to make posting content much more simplified. I'm also using a custom template file to arrange the content the way I want.

    I also have been able to do the left aligned thumbnail with the automatically generated excerpt. Check out this website I work on for an example.

  4. nimrod
    Member

    Thanks for the responses. @Jawillde: just wondering how this differs from the basic instructions on adding custom post types in any functions.php file regardless of the template or framework...?

    Also, you say in the end that you used a custom template file to show the custom field entries. This is what I am trying to avoid in favor of more elegant and simple solutions within Thematic so that I do NOT have to add a bunch of custom files with redundant code.
    _________

    Still, regardless of using custom template files or not, my burning question is can I integrate the info from a custom post type with taxonomies and then display the custom info both in a loop page AND in a single post page with everything styled and sortable?

    To use your example, I'd want to see an initial Stories loop page with multiple Story titles, excerpts, AND maybe a custom taxonomy for Story Author and Story Date (NOT the date the custom post type was published).

    This loop could be sorted alphabetically by title or perhaps the Story Date is more important and all items in the loop are sorted DESC using the Story Date custom taxonomy.

    Obviously, I'd want to see a single page of each Story with all the custom bits styled and displayed nicely.

    What would ice the cake is, like More Fields capability, I'd like any instance of the author name to be a link to a loop page of all stories by that author (which would make sense to sort by Story title, of course).
    _________

    In other words, just being able to create custom post types / taxonomies is less than half the battle (there is a ton of info online about this basic first step). I need to also intelligently display and sort that info in useful ways. This is where I'm having a hard time finding examples.

    Posted 3 years ago #
  5. Here is a CPT plugin.........

    http://wordpress.org/extend/plugins/custom-field-template/

    I just recently downloaded it myself, so I don't know much about it yet, but it seems to be a neat plugin.

    Posted 3 years ago #
  6. Justin Tadlock has a relatively new post that might help you.

    It is about marrying CPTs and taxonomies and as far as I can tell (i don't know enough about CPTs or especially about taxonomies to understand what you are asking) that appears to address what you are trying to do.

    http://justintadlock.com/archives/2010/08/20/linking-terms-to-a-specific-post

    i've been moving towards doing completely away w/ custom fields and replacing them with meta boxes. it can be helllla configurable... putting certain boxes on certain templates or certain post types. i had dabbled a bit with it and it was medium complicated EXCEPT that another brilliant WP guy named Dimas Begunoff created a php class that you can include and it takes care of generating, saving and recalling all the custom info you could want... basically all you do is define the box, and then write the inputs you want in HTML.

    http://farinspace.com/wpalchemy-metabox/

    as i read through Tadlock's post, maybe what you could do is create a metabox that allows you to select the post type?

    again- i don't really understand what you are describing.... i am going to need to dabble in this a lot more.

    Posted 3 years ago #
  7. Hey there. WordPress does not support multiple-customposttype.php templates out of the box. You won't find any theme that has a default template for that, including Thematic.

    You either need to use a plugin, or some custom code. For instance, you could use Michael Field's code snippet and tell it to load index.php by default for you custom post types: http://wordpress.mfields.org/2010/custom-content-type-add-theme-redirect/

    Your single custom post types should get pulled up under the single.php Thematic template. Or you can create your own new templates in the child theme called single-customposttype.php- but I'm not sure if all the body class functionality is yet there (haven't checked the latest Thematic build).

    If you use a plugin like http://wordpress.org/extend/plugins/simple-custom-post-type-archives/ a lot of the paging issues etc. will be taken care of.

    Again, Thematic is great for a lot of sites- but if you are doing major customizations to post display and serious alterations that go beyond the stylesheet, it often makes sense not to use a framework like Thematic. That's why I chose to do my Portfolio theme using Ian Stewart's toolbox. It'll save you a ton of headaches by not having to figure out what the filter, hook, etc.

    If you want to see an example how of how custom post types work in a child theme, check out my events theme: http://wptheming.com/2010/08/how-to-make-an-events-custom-post-type/ (It's a child theme of TwentyTen).

    If you want information on how to add metaboxes to a child theme, check out: http://wptheming.com/2010/08/custom-metabox-for-post-type/

    Good luck!

    Posted 3 years ago #
  8. nimrod
    Member

    This is excellent info! Thanks for the helpful responses, all.

    I just found an interesting plugin that allows archive-style display via CPTs with some hook flexibility too:

    http://ratvars.com/custom-post-type-archives/

    Also this one with slightly different usage:

    http://wordpress.org/extend/plugins/simple-custom-post-type-archives/

    Posted 3 years ago #
  9. Danieliser
    Member

    I have a custom field script ive been working on, dont have the admin area done yet but it creates custom write panels for any post type, these panels can have subpanels and any type of form field below. Works great with Custom Post types for creating custom write panels. If i get enough interest i might start up a new plugin.

    Posted 3 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.