如何覆盖模板

时间:2015-08-09 12:22:43

标签: php wordpress override

我正在为Wordpress设计一个模板。默认情况下,Wordpress以下列方式打印帖子,

<div class="vevent_list rMarginLg">
<div id="L20150808ld" class="entry">
  <h3 class=""><a rel="bookmark" href="link">Hello world!</a></h3>
  <p class="date"><span title="2015-08-08T02:09:51+0000" class="dtstart published">08 August 2015</span> | <a href="link/#comments">Comments (1)</a></p>
  <p>Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!</p>
    <!--p class="meta">  &#8212;   
       </p -->
    <div class="feedback">
            </div>
</div>
</div>

但我希望以下列方式打印,

<div class="c1">
      <div class="c2">
         <h3 class="c3">
            <span class="c4"><a href="link">Hello world!</a></span>
         </h3>
         <p class="c5">
            <span title="2015-08-08T02:09:51+0000" class="dtstart published"> 08 August 2015 </span>
         </p>
      </div>
      <div class="c6"><p>Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!</p>
</div>

我想以正确的方式做到这一点,而不是操纵wordpress核心功能。我怎样才能做到这一点?有没有相关的教程?

1 个答案:

答案 0 :(得分:1)

您可以在主题中编辑single.php。

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div class="c1">
      <div class="c2">
         <h3 class="c3">
            <span class="c4"><a href="<?php the_permalink();?>"><?php the_title();?></a></span>
         </h3>
         <p class="c5">
            <span title="<?php the_date();?>" class="dtstart published"><?php the_date();?></span>
         </p>
      </div>
      <div class="c6"><?php the_content();?></div>
</div>

<?php endwhile; else : ?>
    <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
<?php endif; ?>
相关问题