简体   繁体   English

如何使用HTML 5以WordPress主题显示帖子?

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

I am pretty new in HTML 5 and I am developing a WordPress theme using HTML 5 and I have the following doubt: 我是HTML 5的新手,并且正在使用HTML 5开发WordPress主题,但我有以下疑问:

I have to put this WordPress code that show all the posts in my page theme 我必须将这个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>

Now in the previous code this php code is wrapped inside a classic XHTML ... block. 现在,在前面的代码中,此php代码包装在经典的XHTML ...块中。 Now I want to optimize the previous code using HTML 5 . 现在,我想使用HTML 5优化先前的代码。

So is it a good choice replace the external ... with a ... ? 那么用...代替外部...是一个好选择吗?

Or are there a better solution? 还是有更好的解决方案?

After do this operation is it a good choice wrap every post using the HTML 5 ... tag? 完成此操作后,使用HTML 5 ...标签包装每个帖子是否是一个不错的选择?

I mean that I replace this code: 我的意思是我替换了这段代码:

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

with something like: 与类似:

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

Is it a good idea? 这是个好主意吗?

Tnx TNX

Andrea 安德里亚

A great reference to check is the underscores (_s) theme . 下划线(_s)主题是对check的很好参考。 It's an HTML5 blank theme maintained by Automattic (the company who owns WP). 这是Automattic(拥有WP的公司)维护的HTML5空白主题。 Here's the template they use: 这是他们使用的模板:

<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 doesn't care which html its templates output, WordPress just echo's the content that's all. WordPress不在乎其模板输出的html,WordPress只是回显所有内容。 Your theme however could depend on the .post class but I guess you're making your own theme 但是,您的主题可能取决于.post类,但是我想您正在制作自己的主题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM