构建一个Bootstrap WordPress主题#7 添加内容和阅读按钮

我们先来添加摘要部分。

  1. 添加内容摘要

我们在9-column的div中添加如下代码:我们在9-column的div中添加如下代码:

</p>

<div class="excerpt">
	 echo get_the_excerpt(); ?>
</div>

到前端刷新页面,摘要出现了

构建一个Bootstrap WordPress主题#7 添加内容和阅读按钮_第1张图片

  1. 添加阅读更多按钮
    在excerpt类下面,使用bootstrap类的btn 和 btn-default创建一个按钮。
    将href属性设置为the_permalink()。 对于文本,我们会说Read More and » 。 我们还将在上面添加一个换行符br。
<br>
<a class="btn btn-default" href="">
 Read More »
a>

刷新前端页面
构建一个Bootstrap WordPress主题#7 添加内容和阅读按钮_第2张图片

  1. 为没有图片的博客帖子设置模式
    我们之前设置无图帖子按照容器全部宽度显示,找到col-md-12 的div,在其内部输入以下代码覆盖IMAGE HERE文本:
<div class="col-md-12">

 <h2>
 <a href="">
  echo the_title(); ?>
 </a>
 </h2>
 <p class="meta">
 Posted at
  the_time(); ?> on 
  the_date(); ?> by 
 <strong> the_author(); ?></strong>
 </p>
 <div class="excerpt">
  echo get_the_excerpt(); ?>
 </div>
 <br>
 <a class="btn btn-default" href="">
 Read More &raquo;
 </a>

现在我们有了没有图片的帖子,而不只是一个空的空间。
构建一个Bootstrap WordPress主题#7 添加内容和阅读按钮_第3张图片
如果我们没有使用条件语句,这里就像一个图片丢失的帖子。

你可能感兴趣的:(WordPress主题制作)