如何覆盖模板中的 wordpress 帖子
How to override wordpress posts in the template
我正在为 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"> —
</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 核心功能。我怎样才能做到这一点?有教程吗?
您可以在主题中编辑 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; ?>
我正在为 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"> —
</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 核心功能。我怎样才能做到这一点?有教程吗?
您可以在主题中编辑 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; ?>