Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 29th, 2012  |  syntax: None  |  size: 2.25 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Multiple editors (TinyMCE) in custom post types
  2. <?php
  3. function keg_product_fields (){
  4. global $post;
  5. $custom = get_post_custom($post->ID);
  6. $keg_product_price = $custom["keg_product_price"][0];
  7. $keg_product_link = $custom["keg_product_link"][0];
  8. $keg_product_type = $custom["keg_product_type"][0];
  9. $keg_product_featured = $custom["keg_product_featured"][0];
  10. $keg_product_summary = $custom["keg_product_summary"][0];
  11. $editor_id = "kegprodsummary"
  12. ?>
  13. <p>
  14. <label>Summary:</label><br />
  15. <?php wp_editor( $keg_product_summary, $editor_id, $settings = array('textarea_name' => 'keg_product_summary') ); ?>
  16. </p>
  17. <p>
  18. <label>Price:</label><br />
  19. <input size="10" name="keg_product_price" value="<?php echo $keg_product_price; ?>" />
  20. </p>
  21. <p>
  22. <label>Type:</label><br />
  23. <select name="keg_product_type">
  24. <option value="<?php echo $keg_product_type; ?>" selected="selected"><?php echo $keg_product_type; ?></option>
  25. <option value="Book">Book</option>
  26. <option value="CD">CD</option>
  27. <option value="Downloadable">Downloadable</option>
  28. <option value="Multimedia">Multimedia</option>
  29. <option value="Virtual">Virtual</option>
  30. </select>
  31. </p>
  32. <p>
  33. <label>Link:</label><br />
  34. <input size="65" maxlength="200" name="keg_product_link" value="<?php echo $keg_product_link; ?>" />
  35. </p>
  36. <p>
  37. <input type="checkbox" name="keg_product_featured" value="Yes" <?php if (!(strcmp("$keg_product_featured","Yes"))) {echo "checked="checked"";} ?>/>
  38. <label>Featured Product</label>
  39. </p>
  40.  
  41. <?php
  42. }
  43.  
  44. function add_keg_product_box (){
  45. add_meta_box(
  46. "keg_product_info",
  47. "Product Details",
  48. "keg_product_fields",
  49. "keg_products"
  50. );
  51. }
  52.  
  53.  
  54. function save_keg_product_attributes ( $post_id )
  55. {
  56. if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) {
  57. return $post_id;
  58. }
  59.  
  60. global $post;
  61. update_post_meta($post->ID, "keg_product_price", $_POST["keg_product_price"]);
  62. update_post_meta($post->ID, "keg_product_link", $_POST["keg_product_link"]);
  63. update_post_meta($post->ID, "keg_product_type", $_POST["keg_product_type"]);
  64. update_post_meta($post->ID, "keg_product_featured", $_POST["keg_product_featured"]);
  65. update_post_meta($post->ID, "keg_product_summary", $_POST["keg_product_summary"]);
  66.  
  67. }
  68.  
  69. add_action ('admin_init', 'add_keg_product_box' );
  70. add_action ('save_post', 'save_keg_product_attributes');
  71. add_action ('publish_post', 'save_keg_product_attributes');
  72. ?>