2014-01-28 40 views
0

我在HTML 5非常新,我使用HTML 5開發一個WordPress主題,我有以下疑問:如何使用HTML 5顯示WordPress主題中的帖子?

我必須把這個WordPress代碼,顯示所有的帖子在我的網頁主題

<div id="content"> 
<?php if (have_posts()) : ?> 

     <?php while (have_posts()) : the_post(); ?> 

      <div class="post"> 
       <h2 id="post-<?php the_ID(); ?>"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2> 
       <small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small> 

       <div class="entry"> 
        <?php the_content('Read the rest of this entry »'); ?> 
       </div> 

       <p class="postmetadata">Posted in <?php the_category(', ') ?> <strong>|</strong> <?php edit_post_link('Edit','','<strong>|</strong>'); ?> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p> 

       <!-- 
       <?php trackback_rdf(); ?> 
       --> 
      </div> 

     <?php endwhile; ?> 

     <div class="navigation"> 
      <div class="alignleft"><?php posts_nav_link('','','« Previous Entries') ?></div> 
      <div class="alignright"><?php posts_nav_link('','Next Entries »','') ?></div> 
     </div> 

    <?php else : ?> 

     <h2 class="center">Not Found</h2> 
     <p class="center"><?php _e("Sorry, but you are looking for something that isn't here."); ?></p> 
     <?php include (TEMPLATEPATH . "/searchform.php"); ?> 

    <?php endif; ?> 

</div> 

現在在前面的代碼中,這個php代碼被封裝在一個經典的XHTML ...塊。現在我想使用HTML 5來優化以前的代碼。

那麼這是一個不錯的選擇替換外部......

還是有更好的解決方案嗎?

做了這個操作後,是不是一個很好的選擇包裝每個職位使用HTML 5 ...標籤?

我的意思是,我將這段代碼:

<div class="post"> 
    .................. 
    .................. 
    .................. 
</div> 

的東西,如:

<article> 
    .................. 
    .................. 
    .................. 
</article> 

這是個好主意嗎?

TNX

安德烈

+1

@AlienArrays沒有我可以使用HTML 4沒有問題,在我看來(也存在使用表impagination一些老orrible模板...) – AndreaNobili

+0

'

'是一個完美的替代爲'
'在這種情況下。 – jono

回答

0

WordPress的不關心哪個HTML模板的輸出,WordPress的只是Echo的這一切的內容。然而,你的主題可能取決於.post班,但我想你正在製作自己的主題

+0

請原諒我,但是你能不能只把這個課程添加到文章中?如果開發者在css中列出了div.post,那麼他們確實需要一個交談;-) – DLaverick

+1

當然你可以添加它,但這並不意味着它會工作。以這個選擇器爲例:'.post-container div'並不少見,因爲這裏有一個可用的類,當然這很奇怪,但是... https://i.chzbgr.com/maxW500/1665425664/ h97A49856 / – user2019515

1

對檢查的很好的參考是underscores (_s) theme。這是由Automattic(擁有WP的公司)維護的HTML5空白主題。下面是他們使用的模板:

<article id="post-{ID#}」 class="post-{ID#} post"> 
    <header class="entry-header"> 
    <h1 class="entry-title」>…</h1> 
    <div class="entry-meta」>…</div> 
    </header> 
    <div class="entry-content」>…</div> 
    <footer class="entry-meta">…</footer> 
</article> 
相關問題