2014-07-09 114 views
0

我使用this tutorial on Wordpress.org。之後,我知道我需要將其改爲顯示5個標題,而不是一個帖子,但我的理解有點有限。我還需要幫助,以顯示「精選」帖子下的帖子及其類別和子類別。WordPress的類別,子類別,循環

謝謝!

到目前爲止,FEATURED部分的代碼。我希望特色部分左側的圖片只是來自最近發佈的第一張圖片,而不管其類別如何。我將使用CSS來添加標題以及不在其上的內容。

<!-- Featured SECTION --> 
<div class="row"> 
    <div class="large-7 columns"> 
    <?php 
     $thumbnails = get_posts('numberposts=1'); 
     foreach ($thumbnails as $thumbnail) { 
     if (has_post_thumbnail($thumbnail->ID)) { 
      echo '<a href="' . get_permalink($thumbnail->ID) . '" title="' . esc_attr($thumbnail->post_title) . '">'; 
      echo get_the_post_thumbnail($thumbnail->ID, 'front-large'); 
      echo '</a>'; 
     } 
     } 
    ?> 
    </div> 
    <div class="large-5 columns latest"> 
    <h5 class="subheader">Featured</h5> 
    <ul> 
    <?php 
    foreach((get_the_category()) as $category) { 
    $the_query = new WP_Query('featured' . $category->category_nicename . '&showposts=5'); 
    while ($the_query->have_posts()) : $the_query->the_post(); 
    ?> 
       <li> 
        <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a> 
       </li> 
    <?php endwhile; ?> 
    <?php 
    } 
    ?> 
    </ul> 
    </div> 
</div><!-- END Featured SECTION --> 

Mockup

+0

的職位,你已經取得的全部信息你能發佈您的代碼,以及您希望它看起來如何? – designtocode

+0

@msbodetti我添加了我編碼的頂部部分。我究竟做錯了什麼? – katiejallred

回答