2012-01-24 21 views
0

我有一個WordPress的網站,我想創建一個博客頁面,它將顯示以下內容。如何獲取博客文章的精選圖片,內容,上次修改日期和評論數量?

  1. 在第一線的博客的特色形象
  2. 在第三行
  3. 最後更新,評論數第二行
  4. 博客內容(文本)的博客標題和發表在第四行。

我該怎麼做?

我直接查詢數據庫或使用一些內置函數?

任何幫助?

+0

請將此問題移至wordpress.stackexchange.com – amolv

回答

0
query_posts(); 
     while (have_posts()) : the_post(); 
     if(has_post_thumbnail()) 
     the_post_thumbnail('medium'); 
     else { 
     $photos = get_children(array('post_parent' => get_the_ID(), 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID')); 
      if ($photos) { 
       $photo = array_shift($photos); 
       echo wp_get_attachment_image($photo->ID, 'medium'); 
      } 
     } 

     echo '<h2 class="entry-title"><a href="'.get_permalink().'" title="'.get_the_title().'">'.get_the_title().'</a></h2>'; 
     the_excerpt(); 

     endwhile; 
     wp_reset_query(); 
相關問題