【问题标题】:How to change heading tag of page builder elements in WordPress?如何在 WordPress 中更改页面构建器元素的标题标签?
【发布时间】:2021-09-15 13:39:54
【问题描述】:

我正在使用一个名为“Delaware”的 WordPress 主题,它利用 WP Bakery 作为其页面构建器。

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

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

这是检查元素显示的内容:

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

或者我怎样才能找到文件的来源以便我可以编辑它?

域名:aidenfinserv.com

【问题讨论】:

    标签: css wordpress wordpress-theming wpbakery


    【解决方案1】:

    除非您向开发人员授予访问权限,否则要找到您的文件并不容易。您可能需要将add_filter 用于使用此代码的钩子之一:https://kb.wpbakery.com/docs/filters/wpb_widget_title/ 进入您的functions.php

    目前我还为您提供了一个香草 JavaScript 解决方案,我已经尝试过了。您可以将 JavaScript 部分粘贴到您的主题选项自定义 JS 或 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();
      });
    });
    <div class="box-testi" style="">
      <div class="box-title">
        <h2>Prisha Matondkar</h2>
        <div class="border"></div>
        <p class="sub-title">Sydney, Australia</p><span class="dl-icon-quote svg-icon"></span></div>
      <p>Highest Quality Accounting Services, They'll Assign Dedicated Accountants to you unlike some other companies. And The Accountants were always cheerful to Listen to my queries. Will Prefer Aiden Finserv instead of hiring our own accounts team</p>
    </div>
    
    
    <div class="box-testi" style="">
      <div class="box-title">
        <h2>Chloe Smith</h2>
        <div class="border"></div>
        <p class="sub-title">Chicago, USA</p><span class="dl-icon-quote svg-icon"></span></div>
      <p>Aiden Finserv Client Dashboard for accounting services is one of the most unique things among any Accountant Firm. I can manage everything and its easier to have everything stacked up in one place. I have worked with 8+ Accountant firms and has never
        seen anything like this.</p>
    </div>

    实时输出:

    【讨论】:

      猜你喜欢
      • 2012-12-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-29
      相关资源
      最近更新 更多