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

filters - how to output HTML tags in post_content and not as plain text

programmeradmin0浏览0评论

Currently I have a post with <strong> and <em> tags, and <p> tags. But they all seem to be being outputted as plain text, and not formatted HTML

I am using laravel blade as my templating engine. I currently have:

@php
   $page = get_page_by_title( 'Test Page' );
   $content = apply_filters( 'the_content', $page->post_content );
@endphp

Which outputs:

<p>This is a test page for development practice.</p> <p>Here is another line etc</p> <p><strong>BOLD TEXT</strong></p> <p><em>ITALIC TEXT</em></p>

When it needs to be:

This is a test page for development practice.

Here is another line etc

BOLD TEXT

ITALIC TEXT

This answer: How to output only the post content suggests to use apply_filters( 'the_content', $post->post_content ); which is what I'm currently doing

how do you have content outputted as HTML and not plain text?

发布评论

评论列表(0)

  1. 暂无评论