繁体   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