簡體   English   中英

如何使用HTML 5以WordPress主題顯示帖子?

[英]How to show posts in a WordPress theme using HTML 5?

我是HTML 5的新手,並且正在使用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

安德里亞

下划線(_s)主題是對check的很好參考。 這是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>

WordPress不在乎其模板輸出的html,WordPress只是回顯所有內容。 但是,您的主題可能取決於.post類,但是我想您正在制作自己的主題

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM