解决WordPress不能使用空行的五种方法

      我们在使用wordpress发布文章的时候,经常可能会遇到在下一个段落的开头,加入一个空行,以突出显示是新的一个大的段落开始了,便于阅读,这个时候你如果不自己访问一下刚才的文章,仅仅在后台的可视化编辑框里使用“shift+回车”的方式加入了一个空行,那么你发布以后,wodpress程序会自动给你删除掉,很郁闷吧。下面告诉你方法来解决它吧。

解决方法一:
      在后台的编辑器里,当需要输入空行的时候,转入“html编辑器”模式,在需要空行的地方输入<br />,然后再发布吧。
      上面的方法有个最大的优点,原生的,不需做任何修改,直接使用。但也有个最大的缺点,就是你每次都要在“html编辑器”模式下输入并接着发布,你一旦转入“可视化编辑器”下编辑并发布以后,那么你以前做的工作就白费了,还得从头再来。下面来介绍彻底一些、简单一些的更好方法吧。

解决方法二:
打开模板目录中single.php文件,查找<?php the_content(); ?>后将其修改为

<div class="entry"><?php the_content(); ?></div>

即可。不过此方法对很多主题无效,如果你也是这样,请继续往下看吧。

 解决方法三:
打开你使用的主题模板目录中style.css文件,添加以下代码:

.post .content {
padding:5px 0 5px 5px;
line-height:145%;
overflow:hidden;
}
.post .content p {
margin-bottom:10px;
}
.post .content .under {
height:16px;
line-height:16px;
}
.post .content .under span {
float:left;
margin-right:15px;
}
.post .content h4 {
color:#080;
margin-bottom:10px;
}
.post .content img {
max-width:600px;
}
.post .content ul,
.post .content ol {
padding-bottom:10px;
}
.post .content ul li,
.post .content ol li {
list-style-position:inside;
padding-left:20px;
}
.post .content table {
background:#FFF;
border:1px solid #CCC;
margin:5px 0 10px;
}
.post .content table tr td {
border-top:1px solid #CCC;
padding:2px 10px;
}
.post .content table tr th {
padding:1px 10px;
background:#EDEFF0;
text-align:left;
}
.post .content .boxcaption {
background-image:url(img/postbox.gif);
border-bottom:1px solid #CCC;
}
.post .content .box {
background-image:url(img/postbox.gif);
}

然后在修改你的single.php文件,查找<?php the_content(); ?>然后修改成

 <div class="post-content"><?php the_content(); ?></div>

即可。

解决方法四:
      此方法实际上是方法三的简单利用吧,解释打开你的style.css文件,查找里面post标签下的 entry p{line-height:20px;margin:0 0 2px 0;} 的类似字段,在这个定义里面增加 margin-bottom:10px; 即可,变成类似这样的结果 entry p{line-height:20px;margin:0 0 2px 0;margin-bottom:10px;} 即可。这种方法比方法三好在不会影响你原有模板的文章排版,而且代码简单,网页打开速度不会受影响。

解决方法五:
      如果你对代码一窍不通,用前面的方法觉得有点麻烦;或者你使用上面的方法仍然不大满意,那么还可以用插件来解决问题!安装TinyMCE Advanced插件吧(wordpress默认的是TinyMCE编辑器,现在安装一个高级版),在插件的设置页面的下方,找到  stop removing the <p> and <br /> tags when saving and show them in the HTML editor 这个选项,打上勾即可。

      本文是下面的文章的丰富版本:http://moesora.com/wordpress-can-not-solve-the-blank-lines-of-three-ways/


100%(8)

0%(0)
发表评论?

7 条评论。

  1. 现在的方法五只要直接回车就可以空行了很方便

  2. 我用的第一种方法!

  3. 最后一个方法挺实用的,呵呵。

  4. 我一直在用啊。
    不过,也许是你使用的版本不同,所以这个方法不合适了?

  5. 博主的方法感觉不太实用,可能是我水平不够吧。

回复给 lucktu ¬
取消回复

*