在Wordpress中为标题添加换行符

时间:2017-08-21 17:44:10

标签: wordpress

我完全是编程新手,我正在创建一个WordPress网站。 我正在尝试在Wordpress标题中添加换行符。

我已经阅读了很多并尝试了很多,但每次我插入一个应该添加换行符的代码时,它都不会破坏该行,它也会阻止我的WordPress工作。 我甚至问过Reddit,但没有人可以提供帮助。

如何在标题中添加换行符?

1 个答案:

答案 0 :(得分:0)

所以好像你想在每个标题上添加一个分界线?!

  

如果可以,拜托,您是否愿意一步一步地教我如何从WordPress标题中划清界限?

如果是这样,那么你需要使用过滤器:

<?php
  function your_custom_filter($title){
       //this function returns the title wrapping div element around it.
       //by default, this should break a line, unless otherwise specified in
       //your css.
       return '<div>' . $title . '</div>';
  }

  add_filter('the_title', 'your_custom_filter');

把它放在你的functions.php中的某个地方 每次调用the_title时都会调用your_custom_filter。我们称之为Hooks. 我希望这会有所帮助。