【问题标题】:Wordpress - WPBakery Page Builder - can I setup several builders for a single page?Wordpress - WPBakery 页面构建器 - 我可以为单个页面设置多个构建器吗?
【发布时间】:2017-11-02 19:01:09
【问题描述】:

我需要为页面设置 2 个内容框。第一个将显示在页眉内,第二个将显示在页面内容中。设计相当复杂,所以我不能使用一个内容框,只是添加一些样式。主要问题是我需要第二个内容框也可以通过 WPBakery Page Builder 进行管理,而且似乎没有这样的功能。也许我可以创建自定义元素,将其添加到第一行,然后挂钩到the_content 过滤器,然后删除包含该元素的行。然后在标题中做几乎相同的事情:检查帖子内容中是否有自定义元素,然后剪掉所有内容并回显我的元素。但我担心 JS 和样式会被破坏。也许有一些插件?

【问题讨论】:

    标签: php wordpress visual-composer


    【解决方案1】:

    我还没有找到可以使用 2 个编辑器的方法,所以我决定让带有“标题”类的行出现在标题和其他内容中 - 在内容部分。

    <?php //functions.php
    /* define which class should we use to separate the content */
    define("CLASS_FOR_HEADER", "header"); 
    define("HEADER_SECTION_REGEX", "/\[vc_row([^\w\]])el_class=(?:\"|'|)(.*?)".CLASS_FOR_HEADER."(.*?)(?:\"|'|)(.*?)\]+(.*?|\n)+\[\/vc_row]/");
    
    /* Used in the header to leave only header section. 
     * header-part-content is a custom action called in the header by
     * apply_filters('header-part-content', $post->post_content);
     */
     add_filter('header-part-content', function ($content) {
        $matches = [];
        preg_match_all(HEADER_SECTION_REGEX, $content, $matches);
        if (empty($matches) || empty($matches[0])) {
            return "";
        }
        return do_shortcode(implode($matches[0]));
    }, 10, 1);
    
    
    /* Used to cut the header elements out of the content */
    add_filter('the_content', function ($content) {
        return preg_replace(HEADER_SECTION_REGEX, "", $content);
    }, 1);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-13
      • 2018-12-18
      • 2020-03-22
      • 2020-02-05
      • 2022-08-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多