最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

theme development - Force Balance Tags not working

programmeradmin2浏览0评论

I am trying to shorten my the_content() word count to 200 while retaining the html formatting as well as the shortcodes. I am pretty close but for some reason, I cannot get force balance tags or balanceTags() to work as intended.

The code I am using is the following

$content = html_entity_decode(wp_trim_words(htmlentities(get_the_content()), 200));
echo force_balance_tags(do_shortcode($content));

If I break the content at 300, its fine, but that is only because it doesnt cut at an html tag. specifically at 200 it is cutting at target="_blank" and not closing the a tag. When i run the balance tags functions, it seemingly does nothing.

How do I get the content, make sure it keeps the formatting and short codes, AND balances the tags regardless of where I end it.

发布评论

评论列表(0)

  1. 暂无评论