php - 自定义 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。有没有办法防止这种情况?
解决方案
推荐阅读
- java - Spring-Boot @PreAuthorize 仅允许对管理员进行操作,或者如果经过身份验证的用户 id 与路径参数 id 相同
- php - 警告:imagedestroy() 期望参数 1 是资源
- azure-cosmosdb - Gremlin 查询返回键/值列表,其中键是顶点 ID,值是特定属性的值
- php - 将 PHP 加密/解密转换为 Node.js
- php - 为什么我无法在每个模态中获取标题和注释?
- jquery - revokeObjectURL 在 mozilla firefox 和 Microsoft Edge 中不起作用
- android - 将 Int 绑定到 TextView 时的 ResourcesNotFoundException
- regex - 将 logstash 中的字段与“$”匹配
- google-cloud-speech - Speech to Text rest API 很慢。如何改进?
- r - 通过终端在 Rstudio 中执行 Wolframscript 代码