【问题标题】:Bootstrap auto generate <p> tag in WordpressBootstrap 在 Wordpress 中自动生成 <p> 标签
【发布时间】:2021-07-23 12:22:15
【问题描述】:

谁能帮我解决这个问题?我在我的 p 标签中使用了the_content(),并且引导程序自动生成更多的p 标签,甚至内容也没有放在p 中。它在另一个p

里面

图片1:

图2:

【问题讨论】:

  • 请在您的问题中添加您的代码而不是图片。

标签: wordpress bootstrap-4 wordpress-theming


【解决方案1】:

因为 the_content() 将始终使用 &lt;p&gt; 标记包装内容。

您可以使用 get_the_content() insted of the_content(),但使用 get_the_content() 将为您提供没有任何短代码或嵌入媒体的内容,如 codex 所述。

这是获得您想要的东西的另一种解决方案:

<?php
$content = get_the_content();
$content = apply_filters('the_content', $content);
$replace = '<p class="discription">';
echo str_replace('<p>', $replace, $content ); ?>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-05-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多