This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Aug 29th, 2012  |  syntax: None  |  size: 1.75 KB  |  views: 16  |  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.         add_action('init', 'create_foo');
  2.         function create_foo() {
  3.         $foo_args = array(
  4.                 'label' => __('Foo'),
  5.                 'singular_label' => __('Foo'),
  6.                 'public' => true,
  7.                 'show_ui' => true,
  8.                 'capability_type' => 'post',
  9.                 'hierarchical' => true,
  10.                 'rewrite' => true,
  11.                 'supports' => array('title', 'editor', 'excerpt', 'thumbnail')
  12.         );
  13.         register_post_type('foo',$foo_args);
  14.         }
  15.  
  16.  
  17.         add_action("admin_init", "add_foo");
  18.         add_action('save_post', 'update_website_url');
  19.         function add_foo(){
  20.             add_meta_box("foo_details", "Foo Options", "foo_options", "foo", "normal", "low");
  21.         }
  22.  function foo_options(){
  23.            global $post;
  24.    if (isset($custom['website_url']) && isset($custom['website_url'][0])) {
  25.    $website_url = isset($custom['website_url']) ? $custom['website_url'][0] : '';}
  26.    ?>
  27.  
  28. <div id="foo-options">
  29. <label>Website URL:</label><input name="website_url" value="<?php echo $website_url; ?>" />        
  30. </div><!--end foo-options-->
  31. <?php
  32.  
  33.    }
  34. {
  35.  
  36.    function update_website_url(){
  37.        global $post;  
  38.        if (($post != null) && isset($_POST['website_url'])) {
  39.        update_post_meta($post->ID, "website_url", $_POST["website_url"]);
  40.      }
  41.   }
  42.  
  43.  
  44.         add_filter("manage_edit-foo_columns", "foo_edit_columns");
  45.         add_action("manage_posts_custom_column",  "foo_columns_display");
  46.         function foo_edit_columns($foo_columns){
  47.         $foo_columns = array(
  48.                 "cb" => "<input type=\"checkbox\" />",
  49.                 "title" => "Project Title",
  50.                 "description" => "Description",
  51.         );
  52.         return $foo_columns;
  53.         }
  54.  
  55.         function foo_columns_display($foo_columns){
  56.         switch ($foo_columns)
  57.         {
  58.                 case "description":
  59.                         the_excerpt();
  60.                         break;                         
  61.         }
  62.         }
clone this paste RAW Paste Data