• 1.
    add_action('init', 'portfolio');
  • 2.
    function portfolio() {
  • 3.
        register_post_type('portfolio', array(
  • 4.
        'label' => __('Portfolio'),
  • 5.
        'singular_label' => __('Portfolio'),
  • 6.
        'public' => true,
  • 7.
        'show_ui' => true,
  • 8.
        'capability_type' => 'post',
  • 9.
        'hierarchical' => false,
  • 10.
        'rewrite' => false,
  • 11.
        'query_var' => "portfolio",
  • 12.
        'supports' => array('title', 'editor', 'thumbnail', 'custom-fields')
  • 13.
    ));
  • 14.
    }
  • 15.
     
  • 16.
    function admin_init(){ 
  • 17.
     add_meta_box("url_portfolio", "Url du portfolio", "url_portfolio", "portfolio", "normal", "low");  
  • 18.
    }
  • 19.
    function url_portfolio(){
  • 20.
     global $post;
  • 21.
     $custom = get_post_custom($post->ID);
  • 22.
     $url_portfolio = $custom["url_portfolio"][0];
  • 23.
     ?>
  • 24.
     <input size="70" type="text" value="<?php echo $url_portfolio;?>" name="url_portfolio"/>
  • 25.
     <?php
  • 26.
     }
  • 27.
    function save_custom(){
  • 28.
     global $post;
  • 29.
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { 
  • 30.
     return $postID;
  • 31.
     }
  • 32.
     update_post_meta($post->ID, "url_portfolio", $_POST["url_portfolio"]); 
  • 33.
     }
  • 34.
     
  • 35.
    add_action("admin_init", "admin_init");
  • 36.
    add_action('save_post', 'save_custom');
add_action('init', 'portfolio'); function portfolio() { register_post_type('portfolio', array( 'label' => __('Portfolio'), 'singular_label' => __('Portfolio'), 'public' => true, 'show_ui' => true, 'capability_type' => 'post', 'hierarchical' => false, 'rewrite' => false, 'query_var' => "portfolio", 'supports' => array('title', 'editor', 'thumbnail', 'custom-fields') )); } function admin_init(){ add_meta_box("url_portfolio", "Url du portfolio", "url_portfolio", "portfolio", "normal", "low"); } function url_portfolio(){ global $post; $custom = get_post_custom($post->ID); $url_portfolio = $custom["url_portfolio"][0]; ?> <input size="70" type="text" value="<?php echo $url_portfolio;?>" name="url_portfolio"/> <?php } function save_custom(){ global $post; if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return $postID; } update_post_meta($post->ID, "url_portfolio", $_POST["url_portfolio"]); } add_action("admin_init", "admin_init"); add_action('save_post', 'save_custom');

Copy Code to Clipboard Raw

Sign-in or Create a Free Account.

Snippi uses Twitter or Facebook to register and create accounts. Registration will enable you to keep track of your snippets. We never spam your timeline or wall. Ever.

Sign-in with Facebook Sign-in with Twitter