需要帮助将filter应用于php-echo


need help applying filter to php echo

我在Wordpress中创建了一个自定义的帖子类型。视觉编辑器显示段落中断,但当查看帖子时,这些中断会消失,这与常规帖子不同。

这是我在singlecustompostype.php文件中的内容代码:

 <?php echo $content = get_the_content(); ?>

我读到我应该添加这个:

$content = apply_filters("the_content",$post->post_content);

但当我这样添加时,没有效果:

<?php $content = apply_filters("the_content",$post->post_content); echo $content = get_the_content(); ?>

我应该采取什么不同的做法?

以下内容能为您解决问题吗?似乎你得到了正确的$content,然后覆盖它…

<?php 
  $content = apply_filters("the_content",$post->post_content); 
  echo $content; 
?>