[英]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.