我创建了一个 WordPress 插件来显示唱片。该插件在标题下插入一个表格,显示艺术家图片等。包括简介和内容所在的文本字段。如果我将内容放入常规段落块中,自动链接插件可以完美工作并根据标签创建内部链接。但插件的内容完全不受影响。我尝试根据块区域的 wordpress 结构向我的表和 div 添加类,但这没有做任何事情。
现在,自动链接插件的开发者声明,“TaxoPress 将处理使用 the_content() 显示的内容,这是 WordPress 标准......开发人员可以使用它,或者他们可以通过以下方式运行输出: $content = apply_filters( 'the_content', $post->post_content );"。这引出了我的问题。
如何设置插件注入表的属性来镜像块区域的属性?
这是通过插件向网站添加内容的代码
<!----------Intro-->
<?php if ($row->ctp_intro): ?>
<table id="contenido">
<tr>
<td style="background: #f8f8f8; border: 1px solid #ddd;">
<?php echo wpautop($row->ctp_intro); ?>
</td>
</tr>
</table>
<?php endif; ?>
<!--Read More-->
<?php if ($row->ctp_texto): ?>
<table id="leermas">
<tr>
<td class="cent" style="background: #fff;">
<span>
<a href="#" id="continuar-toggle" style="color: #657f9b;"
onclick="event.preventDefault(); toggleTexto();">Leer más</a>
</span>
</td>
</tr>
</table>
<?php endif; ?>
<!----------Text-->
<?php if ($row->ctp_texto): ?>
<table id="oculto" style="border:0;">
<tr id="ctp-texto" style="display: none;">
<td style="background: #f8f8f8; border: 1px solid #ddd;">
<?php echo wpautop($row->ctp_texto); ?>
</td>
</tr>
</table>
<!----------Javascript Read More-->
<script type="text/javascript">
function toggleTexto() {
var textoRow = document.getElementById("ctp-texto");
var continuarToggle = document.getElementById("continuar-toggle");
if (textoRow.style.display === "none") {
textoRow.style.display = "table-row";
continuarToggle.textContent = "Cerrar";
} else {
textoRow.style.display = "none";
continuarToggle.textContent = "Leer más";
}
}
</script>
<?php endif; ?>`
除其他事项外,我尝试使用 WordPress 块区域中的类和 id,但我找不到一种方法来完成这项工作。简而言之,我的插件无法提供对块区域的一些识别或标记。有人见过这样的事情吗?
默认情况下,
the_content()
将呈现 wp_posts 表中 post_content 列的内容。但是您可以使用挂钩(post_content 过滤器)在数据库获取和渲染之间修改此内容。使用此过滤器添加您的表格,然后它将成为 the_content()
的一部分,并且其他插件将看到它。