首页 > 解决方案 > 放弃 Wordpress post_content?

问题描述

我的问题是我想要 give out post_content,但输出是原始简码和 HTML。

我需要一个正确翻译的输出。

链接应该是链接而不是href,而只是带有链接的普通文本。

当帖子中有媒体文件时,我想忽略它。

我不想对我的帖子进行大预览 - 只是一个简单的。

我的输出代码:

$html .= '<p>'.string_limit_words($numpost->post_content, 20).'</p>';

标签: wordpressposts

解决方案


您需要$numpost->post_content通过the_content过滤器,如下所示:

apply_filters( 'the_content', $numpost->post_content )

进一步阅读:https ://developer.wordpress.org/reference/hooks/the_content/


推荐阅读