如何使用自定义wordpress元框添加添加文件上传

时间:2015-08-14 06:07:23

标签: wordpress

我如何轻松添加metabox文件上传地点.Didnt想要使用插件。我已经添加了带文本的元数据但有文件上传我有点困惑。这里是添加文本元数据的代码

function cd_meta_box_music() {
global $wpdb;
$musicLink = get_post_meta(get_the_ID(), 'musicLink', true);
wp_nonce_field('my_meta_box_nonce', 'meta_box_nonce');
global $blog_id;
$posts = $wpdb->get_results('SELECT ID, post_title FROM wp_posts WHERE post_status = "publish" AND post_type = "video-list" ORDER BY ID DESC LIMIT 10000');
?>
<p>
    <label for="musicLink">Put link here</label><br/>
    <input style="margin-top: 15px;width:100%;" type="text" name="musicLink" value="<?php echo $musicLink; ?>"><br/> 
</p><?php
 $factstitle = get_post_meta(get_the_ID(), 'factstitle', true);?>
 <p>
    <label for="factstitle">Interesting facts title</label><br/>
    <input style="margin-top: 15px;width:100%;" type="text" name="factstitle" value="<?php echo $factstitle; ?>"><br/> 
</p><?php
$factssubtext = get_post_meta(get_the_ID(), 'factssubtext', true);?>
<p>
    <label for="factstitle">Put interesting facts subtext here</label><br/>
    <input style="margin-top: 15px;width:100%;" type="text" name="factssubtext" value="<?php echo $factssubtext; ?>"><br/> 
</p><?php
?>
<?php

}

1 个答案:

答案 0 :(得分:1)

你能看出这个问题对你有帮助吗?我不确定,但我认为他是在问同样的事情或几乎相同的

https://wordpress.stackexchange.com/questions/67065/properly-add-an-upload-media-button-in-a-meta-box-field