问题描述
我正在使用名为“特拉华州”的 wordpress 主题,该主题使用 WP Bakery 作为其页面构建器。
问题在于他们在 WP Bakery 中的一些自定义元素不提供更改标题标签的选项。
<div class ="Box-title"><h2>Chloe Smith</h2><div class="border"></div>
或者我如何找到文件的来源以便我可以编辑它?
域名:aidenfinserv.com
解决方法
除非您向开发人员授予访问权限,否则很难找到您的文件。您可能需要将 add_filter
用于使用以下代码的钩子之一:https://kb.wpbakery.com/docs/filters/wpb_widget_title/ 进入您的functions.php
目前我也有一个普通的 JavaScript 解决方案供您使用。您可以将 JavaScript 部分粘贴到您的主题选项自定义 JS 或 {{1}} 文件中。
script.js
const boxTitlesh2 = document.querySelectorAll(".box-title h2");
document.addEventListener("DOMContentLoaded",() => {
boxTitlesh2.forEach((boxTitleh2) => {
const boxTitleh3 = document.createElement("div"); // Replace with your custom element
boxTitleh3.innerText = boxTitleh2.innerText; // You can replace it with your custom text.
boxTitleh3.setAttribute("class","custom-heading"); // Better for styling purposes
boxTitleh2.insertAdjacentElement('beforebegin',boxTitleh3);
boxTitleh2.remove();
});
});
实时输出: