我刚刚在wordpress中为我的自定义post_type添加了一个meta_box,而我的两个额外的wp_editors只是消失了。
我有这样的代码:
$args = array(
'post_type' => 'attachment',
'post_status' => 'any',
'posts_per_page' => -1,
'post_mime_type' =>'application/pdf, image/jpeg, image/gif, image/jpg, image/png'
);
$tmp = $post;
// The Query
$the_query = new WP_Query( $args );
// The Loop
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
$the_query->the_post();
//some code for showing result etc...
}
}
$post = $tmp;
wp_reset_postdata();
我已将其范围缩小到这个“post_status' => '任何' 如果我将帖子状态更改为其他内容,例如: 发布,页面,自定义等...
不是任何或继承..
我得到了我的wp编辑器但是没有从查询中得到任何结果...... 我在这里遗失了什么?
答案 0 :(得分:0)
找到了修复!如果其他人面临同样的问题,将WP_Query更改为query_posts()...
$args = array(
'post_type' => 'attachment',
'post_status' => 'inherit',
'posts_per_page' => -1,
'post_mime_type' =>'application/pdf, image/jpeg, image/gif, image/jpg, image/png'
);
$tmp = $post;
// The Query
$the_query2 = query_posts( $args );
if ( $the_query2 ) {
echo '<select class="bw_selector" name="bw_vendor_material">';
echo '<option value="">Choose attachment:</option>';
// The Loop
foreach ($the_query2 as $key => $value) {
//print_r($value->ID);
echo '<option value="'.$value->ID.'">' . $value->post_mime_type .': '. get_the_title($value->ID) . '</option>';
}
echo '</select>';
echo '<br/>';
}
else {
echo "No posts found";
}
// Restore original Post Data
wp_reset_query();
$post = $tmp;