Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've added a few different custom_post_types to my Wordpress 3 installation. They are all a bit different from eachother, and should store unique information in custom_fields. But while one may store a product_id, another will not. One will have a source_url and another will not. Rather than having to instruct my editors on which custom fields should be used with which custom posts, how can I make each custom post include its custom fields as part of the UI itself?

If you visit "daily_cartoon" you would have a screen that asks only for a title, caption, and media.
If you visit "daily_product" you would have a screen that asks only for a title, price, summary, etc.

share|improve this question
    
@Jonathan Sampson: I'm working all weekend on a package to address this (I've been working on it for over a month.) But I have a deadline of Tuesday so no answering StackExchange questions for me this weekend. If this is still unresolved later next week I'll definitely address it. –  MikeSchinkel Sep 4 '10 at 19:27
    
@MikeSchinkel I'm actually still working on the project, so if you finished your tool already I'd be more than happy to give it a spin and share my experience. –  Jonathan Sampson Sep 12 '10 at 4:02
    
Hi @Jonathan Sampson: I'm not ready to publish it yet but I can work with you privately as my first beta tester if you like. Contact me via email, my email address is on my user profile page: wordpress.stackexchange.com/users/89/mikeschinkel –  MikeSchinkel Sep 12 '10 at 6:20

3 Answers 3

up vote 4 down vote accepted
+50

Hi @Jonathan Sampson:

There are several plugins to make Custom Post Types easier and some allow you to define Custom Fields too, in no particular order:

As I mentioned above I've been working on one that does not provide a User Interface like these to instead an extensible API for complex field types (and simple ones too.) But after spending an hour trying to package it I realized it's not ready for distribution yet. Maybe in a few weeks.

These plugins listed above should meet your basic needs for now and I will try to make mine compatible with the data stored by all of these in the future in case you do decided to use mine in the future.

You also might find this post a bit of help too:

share|improve this answer
    
I'll mark fave this question and will wait your solution ;) –  ariefbayu Sep 12 '10 at 23:37
    
@silent: Cool! –  MikeSchinkel Sep 13 '10 at 1:27

I have recently needed to address a very similar problem while working within a theme. The basis of the code was from this post and I had modified some of the code

The following is the first portion of the code I had modified.

    add_action('init', 'limited_post_type');
function my_custom_limited_post_type() 
{
  $labels = array(
    'name' => _x('Limited Post Type', 'post type general name'),
    'singular_name' => _x('Film - DVD', 'post type singular name')
  );
  $args = array(
    'labels' => $labels,
    'public' => true,
    'publicly_queryable' => true,
    'show_ui' => true, 
    'query_var' => true,
    'rewrite' => true,
    'capability_type' => 'post',
    'hierarchical' => false,
    'menu_position' => null,
    'supports' => array('title','editor','author','thumbnail','excerpt', 'page-attributes','custom-fields' ),
    'show_in_nav_menus' => true
  ); 
  register_post_type('limited_post_type', $args);
}

The following is the second portion of the code I had modified.

foreach ( $scope as $scopeItem ) {
       switch ( $scopeItem ) {
           case "post": {
             // Output on any post screen
             if ( basename( $_SERVER['SCRIPT_FILENAME'] )=="post-new.php" || $post->post_type=="post" )
             $output = true;
             break;}              
            case "page": {
                  // Output on any page screen
                  if ( basename( $_SERVER['SCRIPT_FILENAME'] )=="page-new.php" || $post->post_type=="page" )
            $output = true;
            break;}
             case "limited_post_type": {
                                // Output on limited post_type onlye
            if ((basename( $_SERVER['SCRIPT_FILENAME'] )=="post-new.php" && $post->post_type=="limited_post_type" ) || (basename( $_SERVER['SCRIPT_FILENAME'] )=="post.php" && $post->post_type=="film_dvd" ))
                   $output = true;
                   break;
                  }

If you like please send me a message and I will gladly send you my functions.php file for your reference. This is definitely the way to make it happen though as I went through many nights of hair pulling as yourself.

share|improve this answer

you can add meta_boxes in order to have the custom fields data stored in them. since add_meta_box can be set according to post_type this will enable you to add different meta_box to different post types.

look at this post for a full example of altering the custom post type new/edit scree.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.