首页 > 解决方案 > 自定义 wordpress 插件-首页中的 table 标签替换为 p 标签

问题描述

嘿伙计们,我正在创建一个小型数据表插件,出于某种未知原因,我的 HTML 输出似乎被剥离了。我要显示的代码是一个简单的数据表。

add_action( 'the_content', 'my_thank_you_text' );
function my_thank_you_text ( $content ) {
    $content .= '   
    <table id="table_id" class="display">
        <thead>
            <tr>
                <th>Column 1</th>
                <th>Column 2</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>Row 1 Data 1</td>
                <td>Row 1 Data 2</td>
            </tr>
            <tr>
                <td>Row 2 Data 1</td>
                <td>Row 2 Data 2</td>
            </tr>
        </tbody>
    </table>
    ';
    return $content;
}

我希望在首页上看到一个表格,但我看到的是以下内容:

<div class="entry-content">
    <p>Column 1 Column 2 Row 1 Data 1 Row 1 Data 2 Row 2 Data 1 Row 2 Data 2</p>
</div><!-- .entry-content -->

Wordpress 似乎正在从我的 $content 中删除 HTML。有没有办法防止这种情况?

标签: phpwordpresswordpress-shortcode

解决方案


推荐阅读