如何在 WordPress 中更改页面构建器元素的标题标签?

问题描述

我正在使用名为“特拉华州”的 wordpress 主题,该主题使用 WP Bakery 作为其页面构建器。

问题在于他们在 WP Bakery 中的一些自定义元素不提供更改标题标签的选项。

有什么办法可以通过编辑核心文件主题编辑器来更改它吗?

以下是检查元素显示内容

<div class ="Box-title"><h2>Chloe Smith</h2><div class="border"></div>

或者我如何找到文件的来源以便我可以编辑它?

域名:aidenfinserv.com

screenshot of webpage

解决方法

除非您向开发人员授予访问权限,否则很难找到您的文件。您可能需要将 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();
  });
});

实时输出:

enter image description here

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...