Jump to content
Killersites Community

sergi

Member
  • Content Count

    5
  • Joined

  • Last visited

Community Reputation

0 Neutral

About sergi

  • Rank
    New member
  1. so glad to know about the missing "{". This whole thing is bringing to light my confusion between CPTs (custom post types) and taxonomy. I've been considering them as inseparable. Am I correct? This is my aim: I have a 2 main categories: Video and Magazine. Furthermore, Videos are either Fiction or Non-Fiction; and Magazines are either Comedy or Drama. Should my code attempt the following: create a CPT for Movies w/ a taxonomy for Comedy and a tax. for Drama? And in addition, create a CPT for Videos, w/ a tax. for Fiction and a tax. for Non-Fiction? Let's say the answer is "yes". How do I code that? Thanks for your patience!!!! Here is my stab at that code, but it breaks. /* create custom posts *** vids */ add_action('init', 'create_vids'); function create_vids() { $labels = array( 'name' => __( 'Vids' ), 'singular_name' => __( 'Vids' ), 'add_new' => __( 'Add New' ), 'add_new_item' => __( 'Add New Mag' ), 'edit' => __( 'Edit' ), 'edit_item' => __( 'Edit Mag' ), 'new_item' => __( 'New Mag' ), 'view' => __( 'View Mag' ), 'view_item' => __( 'View Mag' ), 'search_items' => __( 'Search Vids' ), 'not_found' => __( 'No Vid Entries found' ), 'not_found_in_trash' => __( 'No Vid Entries found in Trash' ), 'parent' => __( 'Parent Vid' ) ); register_post_type( 'vid', array( 'labels' => $labels, 'public' => true, 'show_ui' => true, 'capability_type' => 'post', 'hierarchical' => false, 'rewrite' => array("slug" => "vids"), 'supports' => array('title', 'editor', 'thumbnail') ) ); } /* create custom posts *** mags */ add_action('init', 'create_mags'); function create_mags() { $labels = array( 'name' => __( 'Mags' ), 'singular_name' => __( 'Mags' ), 'add_new' => __( 'Add New' ), 'add_new_item' => __( 'Add New Mag' ), 'edit' => __( 'Edit' ), 'edit_item' => __( 'Edit Mag' ), 'new_item' => __( 'New Mag' ), 'view' => __( 'View Mag' ), 'view_item' => __( 'View Mag' ), 'search_items' => __( 'Search Mags' ), 'not_found' => __( 'No Mag Entries found' ), 'not_found_in_trash' => __( 'No Mag Entries found in Trash' ), 'parent' => __( 'Parent Mag' ) ); register_post_type( 'mag', array( 'labels' => $labels, 'public' => true, 'show_ui' => true, 'capability_type' => 'post', 'hierarchical' => false, 'rewrite' => array("slug" => "mags"), 'supports' => array('title', 'editor', 'thumbnail') ) ); } /* create custom taxonomy Vid */ add_action('init', 'build_taxonomy', 0); function build_taxonomy() { // begin Vid $labels = array( 'name' => _x( 'Vid Types', 'taxonomy general name' ), 'singular_name' => _x( 'Vid Type', 'taxonomy singular name' ), 'search_items' => __( 'Search Vid Types' ), 'all_items' => __( 'All Vid Types' ), 'parent_item' => __( 'Parent Vid Type' ), 'parent_item_colon' => __( 'Parent Vid Type:' ), 'edit_item' => __( 'Edit Vid Type' ), 'update_item' => __( 'Update Vid Type' ), 'add_new_item' => __( 'Add New Vid Type' ), 'new_item_name' => __( 'New Vid Type' ), ); register_taxonomy( 'type', 'vid', array( 'hierarchical' => true, 'labels' => $labels, 'query_var' => true, 'rewrite' => true ) ); } /* create custom taxonomy Mag */ add_action('init', 'build_taxonomy', 0); function build_taxonomy() { // begin Mag $labels = array( 'name' => _x( 'Mag Types', 'taxonomy general name' ), 'singular_name' => _x( 'Mag Type', 'taxonomy singular name' ), 'search_items' => __( 'Search Mag Types' ), 'all_items' => __( 'All Mag Types' ), 'parent_item' => __( 'Parent Mag Type' ), 'parent_item_colon' => __( 'Parent Mag Type:' ), 'edit_item' => __( 'Edit Mag Type' ), 'update_item' => __( 'Update Mag Type' ), 'add_new_item' => __( 'Add New Mag Type' ), 'new_item_name' => __( 'New Mag Type' ), ); register_taxonomy( 'type', 'mag', array( 'hierarchical' => true, 'labels' => $labels, 'query_var' => true, 'rewrite' => true ) ); } /* custom columns */ add_filter("manage_edit-video_columns", "edit_columns" ); add_action("manage_posts_custom_column", "custom_columns"); function edit_columns($columns) { $columns = array( "cb" => "<input type ='checkbox' />", "title" => "Video Title", "description" => "Description", "price" => "Length", "type" => "Video Type" ); return $columns; } function custom_columns($column) { global $post; switch ($column) { case "description": the_excerpt(); break; case "length": $custom = get_post_custom($post->ID); echo $custom['length'][0]; break; case "type": echo get_the_term_list($post->ID, 'type', '', ', ', ''); break; } }
  2. Ah! Well, worst comes to worst, I'll use Custom Post UI plugin. But I'm really interested in figuring out how to accomplish multiple post types. Appreciate any insight you have into this dirty work. <? /* create custom posts *** mags */ add_action('init', 'create_mags'); function create_mags() { $labels = array( 'name' => __( 'Mags' ), 'singular_name' => __( 'Mags' ), 'add_new' => __( 'Add New' ), 'add_new_item' => __( 'Add New Mag' ), 'edit' => __( 'Edit' ), 'edit_item' => __( 'Edit Mag' ), 'new_item' => __( 'New Mag' ), 'view' => __( 'View Mag' ), 'view_item' => __( 'View Mag' ), 'search_items' => __( 'Search Mags' ), 'not_found' => __( 'No Mag Entries found' ), 'not_found_in_trash' => __( 'No Mag Entries found in Trash' ), 'parent' => __( 'Parent Mag' ) ); register_post_type( 'mag', array( 'labels' => $labels, 'public' => true, 'show_ui' => true, 'capability_type' => 'post', 'hierarchical' => false, 'rewrite' => array("slug" => "mags"), 'supports' => array('title', 'editor', 'thumbnail') ) ); } /* custom inputs */ add_action('admin_init', 'admin_init'); add_action('save_post', 'save_options'); function admin_init() { add_meta_box( "vidInfo-meta", "Video Options", "video_options", "video", "normal", "low" ); } function video_options() { global $post; $custom = get_post_custom($post->ID); $length = $custom['length'][0]; echo '<label style="padding-right:40px;">Length:</label> <input name="length" value="'. $length . '" style="width:250px;" />'; } /* starting here, error */ function mag_options() global $post; $custom = get_post_custom($post->ID); $issue = $custom['issue'][0]; echo '<label style="padding-right:40px;">Issue:</label> <input name="issue" value="'. $issue . '" style="width:250px;" />'; } /* how to create save_options for both mag and video? */ function save_options() { global $post; if (!isset($_POST['length']) || $post->post_type != 'video') { return $post; } update_post_meta($post->ID, "length", $_POST['length']); } /* create custom taxonomy */ add_action('init', 'build_taxonomy', 0); function build_taxonomy() { // begin Vid $labels = array( 'name' => _x( 'Video Types', 'taxonomy general name' ), 'singular_name' => _x( 'Video Type', 'taxonomy singular name' ), 'search_items' => __( 'Search Video Types' ), 'all_items' => __( 'All Video Types' ), 'parent_item' => __( 'Parent Video Type' ), 'parent_item_colon' => __( 'Parent Video Type:' ), 'edit_item' => __( 'Edit Video Type' ), 'update_item' => __( 'Update Video Type' ), 'add_new_item' => __( 'Add New Video Type' ), 'new_item_name' => __( 'New Video Type' ), ); register_taxonomy( 'type', 'video', array( 'hierarchical' => true, 'labels' => $labels, 'query_var' => true, 'rewrite' => true ) ); } /* custom columns */ add_filter("manage_edit-video_columns", "edit_columns" ); add_action("manage_posts_custom_column", "custom_columns"); function edit_columns($columns) { $columns = array( "cb" => "<input type ='checkbox' />", "title" => "Video Title", "description" => "Description", "price" => "Length", "type" => "Video Type" ); return $columns; } function custom_columns($column) { global $post; switch ($column) { case "description": the_excerpt(); break; case "length": $custom = get_post_custom($post->ID); echo $custom['length'][0]; break; case "type": echo get_the_term_list($post->ID, 'type', '', ', ', ''); break; } } ?>
  3. In the WordPress video on Custom Post Types, Ben teaches us how to create a custom post type of Products. It's easy enough to have 2 custom post types by simply using add_action then register_post_type. However, I can't seem to replicate the other features he add to that custom post type: the inpu, the taxonomy and the columns. this is the point at which things start to break: function video_options() { global $post; $custom = get_post_custom($post->ID); $length = $custom['length'][0]; echo '<label style="padding-right:40px;">Length:</label> <input name="length" value="'. $length . '" style="width:250px;" />'; } function mag_options() global $post; $custom = get_post_custom($post->ID); $issue = $custom['issue'][0]; echo '<label style="padding-right:40px;">Issue:</label> <input name="issue" value="'. $issue . '" style="width:250px;" />'; } this part comes next and I'm not sure how to handle it, either: function save_options() { global $post; if (!isset($_POST['length']) || $post->post_type != 'video') { return $post; } update_post_meta($post->ID, "length", $_POST['length']); } I wonder if somebody can help me tackle this. Thanks much.
  4. yeah, this is what ended up working: add_theme_support( 'post-thumbnails', array( 'post', 'video', 'magazine' ) ); thanks!
  5. my theme supports post-thumbnails. they work when i am adding a post. however, i don't have the option to add them when i'm creating a Custom Post Type. i've completed Ben Falk's Custom Post Types videos, but I'm using Coyier's Blank Theme, not twentyten. still, I have the array that should allow the thumbs to work in my register_post_types funtion, e.g., 'supports' => array('title', 'editor', 'thumbnail') Anyone have any suggestions? Thanks Sergi
×