我已提及此链接multiple image upload from frontend in wordpress,用于向帖子添加多个图片。 代码正在运行,即图片正在上传到媒体库,但没有在帖子中显示,请您告诉我是否必须在Post中创建一个字段来存储它们。如果是的话怎么样?
提交帖子的代码:
public synchronized void guardedJoy() {
// This guard only loops once for each special event, which may not
// be the event we're waiting for.
while(!joy) {
try {
wait();
} catch (InterruptedException e) {}
}
System.out.println("Joy and efficiency have been achieved!");
}
public synchronized notifyJoy() {
joy = true;
notifyAll();
}
Php处理表格:
if(is_user_logged_in()== true) {
<div class="new-post">
<form action="" method="post" enctype="multipart/form-data">
<div class="form-group">
<label for="title">Title :</label><br />
<input class="form-control" type="text" id="title" value="" tabindex="1" size="20" name="title" minlength="5" required />
</div>
<div class="form-group">
<label for="description">Description :</label><br />
<textarea class="form-control" id="description" tabindex="3" name="description" cols="50" rows="6" minlength="30" required></textarea>
</div>
<div class="form-group">
<?php
$args_drop = array(
'show_option_none' => 'Category',
'hide_empty' => false,
'include' => '26, 27, 29, 34, 33',
'tab_index' => 3,
'taxonomy' => 'category',
);
wp_dropdown_categories($args_drop);
?>
</div>
<div class="form-group">
<label for="file">Image 2 :</label>
<input type="file" name="custom_1" value="Custom Field 1 Content" />
</div>
<div class="form-group">
<label for="postPhoto1">Photo 1 :</label>
<input type="file" name="upload_attachment[]" id="postPhoto1">
</div>
<div class="form-group">
<label for="postPhoto1">Photo 2 :</label>
<input type="file" name="upload_attachment[]" id="postPhoto2">
</div>
<input type="submit" value="Submit" tabindex="6" id="submit" name="submit" />
<input type="hidden" name="post_type" id="post_type" value="domande" />
<input type="hidden" name="action" value="post" />
<?php wp_nonce_field( 'new-post' ); ?>
</form>
}
现在的问题是,通过这段代码,我可以上传图片,但是我将它们保存在帖子中。如特色图片在帖子中有一个保存部分,或者如何将它们检索到页面?
由于