WordPress文章摘要支持HTML标签-电脑资料

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

WordPress文章摘要支持HTML标签-电脑资料
在进行 WordPress 主题开发的时候,使用 the_excerpt() 调用出来的文章摘要是不支持HTML 标签的,但我们还是可以通过filter 的方法来让文章摘要支持 HTML 标签,可以在主题的 functions.php 里加入以下代码,。

<span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">add_filter</span><span class="sh_symbol">(</span><span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'the_excerpt'</span><span
class="sh_symbol">,</span> <span style="color: rgb(255, 0, 255); font-weight: normal; font-style. normal; " class="sh_string">'excerpt_force_balance_tags'</span><span class="sh_symbol">);</span> <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">function</span> <span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">excerpt_force_balance_tags</span> <span class="sh_symbol">(</span>$output<span
class="sh_symbol">)</span> <span class="sh_cbracket">{</span> <span style="color: rgb(165, 42, 42); font-weight: normal; font-style. normal; " class="sh_keyword">return</span> $output <span class="sh_symbol">=</span> <span style="color: rgb(0, 0, 0); font-weight: bold; font-style. normal; " class="sh_function">force_balance_tags</span><span
class="sh_symbol">(</span>$output<span
class="sh_symbol">);;</span> <span
class="sh_cbracket">}</span>
如果真的需要让文章摘要支持HTML 标签,建议加上条件判断,不要在 RSS 中将文章摘要里的 HTML 代码展示出来,
电脑资料
《WordPress文章摘要支持HTML标签》(https://www.)。

相关文档
最新文档