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.

Is there a way (plugin, or something else) to set it where there is a drop down on the "New Post" page that allows you to choose a post type and the fields change allowing you to filter what content you are putting into a post without confusing a user by having 20 different custom fields on the "New Post" page.

Also, is there a plugin or other that can make custom fields with different value types (textarea, list, file upload, etc)?

share|improve this question
    
Welcome to WordPress Answers on StackExchange. Glad to have you here. Since you are new and likely unfamiliar with how things are designed to work here I'd like to let you know that you should only ask one question per question so please answer another question about the custom fields with different value types. –  MikeSchinkel Feb 4 '11 at 12:12
    
I apologize, is there an easy way to do that without creating two questions? And is there a way to mark two answers correct on one question? –  Jo Albright Feb 4 '11 at 14:07
add comment

2 Answers

up vote 1 down vote accepted

This was asked over and over:

and if you are not into coding the you can use plugins like

hope this helps

share|improve this answer
    
+1 for More Fields, great plugin for custom fields. –  t31os Feb 4 '11 at 12:07
    
@t31os - I've used More Fields but don't like how it implements fields. IMO Simple Fields better hits the mark, but nothing does a great job (yet). –  MikeSchinkel Feb 4 '11 at 12:33
    
I'd not seen any other plugin work like "More Fields", at least until now, "Simple Fields" looks great(thanks for mentioning), i'll give that a shot next time i'm looking for that functionality. –  t31os Feb 4 '11 at 13:45
    
After testing these plugins, I believe Simple Fields to be the quickest and closest plugin to the feature I am looking for. Although I wish you could change the post type before a user saves the post. - On a side note, I don't think More Fields is that great since it has no file upload (only file-list). –  Jo Albright Feb 4 '11 at 13:58
    
Choosing this as the answer since it is the fastest way for me to implement my desired result. –  Jo Albright Feb 4 '11 at 13:58
add comment

Hi @Jo Albright:

I understand your concern; if you get a lot of post types WordPress' admin menu quickly grows unwieldy. What I've done for you is to implement something like what you asked for. It creates a post edit page metabox for the new post page with a drop down list of custom post types like this:

WordPress Custom Post Type Selector Metabox

And here's what it looks like with a bunch of custom post types in the drop down mode:

What it does is use jQuery and Javascript to modify window.location.href in the browser's DOM upon selection using one of the following URL patterns, using the post types in my list of screenshots as an example:

http://example.com/wp-admin/post-new.php // This is for post_type=post
http://example.com/wp-admin/post-new.php?post_type=page 
http://example.com/wp-admin/post-new.php?post_type=actor
http://example.com/wp-admin/post-new.php?post_type=movie
http://example.com/wp-admin/post-new.php?post_type=car 
http://example.com/wp-admin/post-new.php?post_type=event
http://example.com/wp-admin/post-new.php?post_type=performer

One thing I worry about is the usability of this, however, so I wrote it to disable the drop down after the user modifies the value of any input field. That way the user can't accidently loose everything they were working on.

The code follows and you can place this in your theme's functions.php file or in a .php file for a plugin that you might be writing:

add_action('add_meta_boxes', 'add_meta_boxes_post_type_switcher',10,2);
function add_meta_boxes_post_type_switcher($post_type,$post) {
  global $pagenow;
  if ($pagenow=='post-new.php') {
    require_once(ABSPATH . 'wp-admin/includes/template.php');
    add_meta_box('post_type_switcher','Change Post Type',
                 'post_type_switcher',$post_type,'side','high');
  }
}
function post_type_switcher($post,$metabox) {
  $post_types = get_post_types();
  $new_post_url = admin_url('post-new.php');
  $js =<<<JS
<script type="text/javascript">
jQuery(document).ready(function ($) {
  $("#post-type-switcher-selector").change(function() {
    var post_type = $(this).find(":selected").val();
    var new_post_type_url = "{$new_post_url}?post_type=" + post_type;
    if (post_type=="post" && "{$new_post_url}"!=window.location.href) {
      window.location.href = "{$new_post_url}";
    } else if (new_post_type_url!=window.location.href) {
      window.location.href = new_post_type_url;
    }
  });
  $(".wp-admin #wpbody-content :input").change(function() {
    $("#post-type-switcher-selector").attr("disabled","disabled");
  });
});
</script>
JS;
  echo $js;
  echo '<select id="post-type-switcher-selector">';
  foreach ( $post_types as $post_type ) {
    $post_type_object = get_post_type_object($post_type);
    if ($post_type_object->publicly_queryable && $post_type!='attachment') {
      echo "\n\t<option ";
      if ( $post_type == $post->post_type ) // Make default first in list
        echo "selected='selected' ";
      echo "value='{$post_type}'>";
      echo $post_type_object->labels->singular_name;
      echo "</option>";
    }
  }
  echo '</select>';
}

So there's the code and it should work for you. If you have any questions about specifics in the code, just ask. However I would recommend you instead consider a consolidated menu like this one instead since I think it creates a more consistent mental model for the user, but the choice is yours!

share|improve this answer
    
This is exactly what i am looking for. Do you see any reason that I could not leave the drop down there and use an alert to ask if the user want to change the type if content has already been added? –  Jo Albright Feb 4 '11 at 13:27
    
@Jo Albright: No reason, but you'll have to code that yourself. '-) Glad I could help. Be generous with the votes. :) –  MikeSchinkel Feb 4 '11 at 13:47
    
Once I hit 15 reputation on this exchange I will give you a vote. I will probably pursue this in the future, but just don't have the time to code all of what I want the post types to be. Thank you for some great code! –  Jo Albright Feb 4 '11 at 14:00
    
@Jo Albright - "...all of what I want the post types to be." What specifically do you want? "Once I hit 15 reputation ..." Done! –  MikeSchinkel Feb 4 '11 at 14:18
    
Honestly as open ended as possible. I have been using expression engine a lot, but not every client can shell out the money to use it. Simple Fields is almost what I want, especially since it features.. Repeatable Custom Fields (major plus), Changing of Post types (even though the user has to save the post to change it when you create a new post), and Field Types such as File. –  Jo Albright Feb 4 '11 at 14:29
add comment

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.