在 wordpress 自定义帖子类型库中添加多个图像

问题描述

我创建了自定义帖子“画廊”,现在我想添加多个画廊项目。请帮助我如何做到这一点。 这是我的代码

//Add custom post type for gallery
function cd_custom_post_gallery(){
    register_post_type('gallery',array(
            'labels' => array(
                            'name' => __( 'Gallery' ),'singular_name' => __( 'Gallery' ),'all_items' => __( 'All Images'),),'taxonomies'   => array(
                            'category','public' => true,'has_archive'=>false,'exclude_from_search' => true,'rewrite' => array('slug' => 'gallery-item'),'supports' => array( 'title','thumbnail' ),'menu_position' => 9,'show_in_admin_bar'   => true,'show_in_nav_menus'   => false,'publicly_queryable'  => false,'query_var'           => false
        )
    );
}
add_action('init','cd_custom_post_gallery');


function cd_get_featured_image($post_ID) {
    $post_thumbnail_id = get_post_thumbnail_id($post_ID);
    if ($post_thumbnail_id) {
        $post_thumbnail_img = wp_get_attachment_image_src($post_thumbnail_id,'featured_preview');
        return $post_thumbnail_img[0];
    }
}

我将添加什么来添加画廊项目。 提前致谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)