2017-08-02 73 views
-2

我做了兩個列表主題如何獲得wordpress空內容列表

1.the posts have featured image and title,but empty content。我想要得到這個清單。

2.and其他帖子與內容列表。

我沒有任何想法,請幫助我

回答

0

嘗試使用下面的代碼:

$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 />'; 
    } 
} 
+0

它不工作...陣列([0] => [1] => [ 2] => [3] =>) – metalbug

+0

現在更新代碼,並檢查它的工作正常。 –

+0

看起來不錯,但如何使用它?輸出數組([0] => WP_Post對象([ID] => 51 [post_author] => 1這個我不明白,對不起我的不好 – metalbug