wordpress - 放弃 Wordpress post_content?
问题描述
我的问题是我想要 give out post_content
,但输出是原始简码和 HTML。
我需要一个正确翻译的输出。
链接应该是链接而不是href,而只是带有链接的普通文本。
当帖子中有媒体文件时,我想忽略它。
我不想对我的帖子进行大预览 - 只是一个简单的。
我的输出代码:
$html .= '<p>'.string_limit_words($numpost->post_content, 20).'</p>';
解决方案
您需要$numpost->post_content
通过the_content
过滤器,如下所示:
apply_filters( 'the_content', $numpost->post_content )
进一步阅读:https ://developer.wordpress.org/reference/hooks/the_content/
推荐阅读
- r - 使用 Big Sur v11.1 将 R 从版本 3 升级到 4.0.3 后的编译包安装问题
- python - Python 插件不会出现在 IDA 7.5 中
- php - 如何使用类别名称从特定类别中获取所有帖子?
- python - TypeError:“torch.dtype”对象不可调用。如何调用这个函数?
- vue.js - VueJS - 如何在没有任何硬代码的情况下使组件完全动态化
- .htaccess - 使用 .htaccess 将 URL 子文件夹转换为参数
- javascript - 表单提交后Antd 4 Checkbox没有价值
- python - RuntimeWarning:从未等待协程“some_xyz_method”
- xml - 使用 pg8000 将 xml 数据插入 PostgreSQL
- javascript - 使用 react 和 JSON-sever 从 API 存储天气数据的问题