【问题标题】:Create Multiple File Upload Metabox in Wordpress在 Wordpress 中创建多个文件上传 Metabox
【发布时间】:2013-10-11 11:18:58
【问题描述】:

我正在尝试创建一个元框来上传多个文件(可以是图像或文件)。

目前我有上传字段及其工作文件,直到我们按下上传并保存数据。

唯一的问题是显示文件。

下面是我的代码,我用来显示元框:

case 'file_list':
                    echo '<input class="cmb_upload_file" type="text" size="36" name="', $field['id'], '" value="" />';
                    echo '<input class="cmb_upload_button button" type="button" value="Upload File" />';
                    echo '<p class="cmb_metabox_description">', $field['desc'], '</p>';
                        $args = array(
                                'post_type' => 'attachment',
                                'numberposts' => null,
                                'post_status' => null,
                                'post_parent' => $post->ID
                            );
                            $attachments = get_posts($args);
                            if ($attachments) {
                                echo '<ul class="attach_list">';
                                foreach ($attachments as $attachment) {
                                    echo '<li>'.wp_get_attachment_link($attachment->ID, 'thumbnail', 0, 0, 'Download');
                                    echo '<span>';
                                    echo apply_filters('the_title', '&nbsp;'.$attachment->post_title);
                                    echo '</span></li>';
                                }
                                echo '</ul>';
                            }
                        break;

1) 目前它向我显示附加到帖子的所有文件,我只需要显示使用此元框上传的文件。

2) 需要文件的小缩略图预览。

问候。

【问题讨论】:

    标签: wordpress metaclass meta-boxes


    【解决方案1】:

    目前它向我显示附加到帖子的所有文件,我只需要显示使用此元框上传的文件。

    • 您可能需要一些特殊的字段或方法来区分

    2) 需要文件的小缩略图预览

    • attachment-id 可以通过 get_the_post_thumbnail 获取你的拇指

    【讨论】:

      猜你喜欢
      • 2017-05-26
      • 2014-06-07
      • 1970-01-01
      • 2011-06-23
      • 2014-04-04
      • 1970-01-01
      • 2014-02-05
      • 1970-01-01
      • 2018-01-12
      相关资源
      最近更新 更多