繁体   English   中英

PHP - 将返回值从wp-function转换为String

[英]PHP - Convert Returned Value From wp-function to String

我在我的网站上使用Wordpress的CMS,我想显示最近的博客帖子,但没有帖子中的HTML标签。 我试过以下,但无济于事。

$content = the_content();
$content = strval($content);
echo strip_tags($content, '<p><a>');

返回以下错误:

Parse error: syntax error, unexpected 'the_content' (T_STRING) in C:\xampp\htdocs\wp\wp-content\themes\My-theme\index.php on line 25

the_content()将直接回显您的内容,以便您收到错误。 尝试

$content = get_the_content(); //returns the content so your $content will have all the contents
$content = strval($content);
echo strip_tags($content, '<p><a>');

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM