代码之家  ›  专栏  ›  技术社区  ›  Uffo

Wordpress:custom_post_type图片上传

  •  0
  • Uffo  · 技术社区  · 16 年前

    有人能帮我添加一个图像字段吗正在上载。此处是我当前的代码!

        add_action('init', 'pictures_portofolio');
    
    function pictures_portofolio() {
        $args = array(
            'label' => __('Bilder'),
            'singular_label' => __('Bilder'),
            'public' => true,
            'show_ui' => true,
            'capability_type' => 'post',
            'hierarchical' => false,
            'rewrite' => true,
            'supports' => array(false)
        );
    
        register_post_type( 'Bilder' , $args );
    }
    
    
    add_action("admin_init", "admin_init");
    add_action('save_post', 'save_the_post');
    
    function admin_init(){
        register_taxonomy("catalog", array("product"), array("hierarchical" => true, "label" => "Kategorien", "singular_label" => "Kategorien", "rewrite" => true));  
    
    }
    
    
    function save_the_post(){
        global $post;
        //update_post_meta($post->ID, "price", $_POST["price"]);
    }
    
    1 回复  |  直到 16 年前
        1
  •  0
  •   fcingolani    16 年前

    如何设置:

    'supports' => array('thumbnail')
    

    ... 你的主题也应该支持缩略图;把它放在你的主题函数.php

    add_theme_support( 'post-thumbnails', array( 'Bilder' ) );
    

    http://codex.wordpress.org/Function_Reference/add_theme_support

    推荐文章