如何获取wordpress空内容列表 [英] How to get wordpress empty content list
本文介绍了如何获取wordpress空内容列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我做了两个列表主题
1.帖子有特色图片和标题,但内容空洞.我想得到这个清单.
2.和其他带有内容列表的帖子.
我不知道,请帮帮我
解决方案
尝试使用以下代码:
$args = 数组('post_type' =>'邮政','post_status' =>'发布','posts_per_page' =>-1,'orderby' =>'ID','订单' =>'desc');$blank_posts = array();$posts = new WP_Query( $args);如果( $posts->have_posts() ):while ( $posts->have_posts() ) : $posts->the_post();$content = get_the_content();if($content == '') {array_push( $blank_posts, $post);}终了;万一;/* 打印所有空白内容帖子 *///echo "";打印_r($blank_posts);/* 环形 */if(!empty($blank_posts)){foreach ($blank_posts 作为 $pst) {回声ID =".$pst->ID .','.标题=".$pst->post_title .'
';}}
i make two list theme
1.the posts have featured image and title, but empty content. i want get this list.
2.and other posts with content list.
I don't have any idea, help me please
解决方案
Try to use below code:
$args = array(
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => -1,
'orderby' => 'ID',
'order' => 'desc');
$blank_posts = array();
$posts = new WP_Query( $args );
if ( $posts->have_posts() ) :
while ( $posts->have_posts() ) : $posts->the_post();
$content = get_the_content();
if($content == '') {
array_push( $blank_posts, $post);
}
endwhile;
endif;
/* print all blank content posts */
//echo "<pre>"; print_r($blank_posts);
/* loop */
if(!empty($blank_posts)){
foreach ($blank_posts as $pst) {
echo "ID= ". $pst->ID . ', '. "Title= ". $pst->post_title .'<hr />';
}
}
这篇关于如何获取wordpress空内容列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文