本文介绍了Visual Composer 未显示特定页面样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我从visual composer查看常规页面时,它工作正常:

http://vrshealth.com/qc2

边距、背景等都有效.

我需要创建一个自定义帖子类型质量检查",并且正在使用 archive-quality-check.php 来显示它,并且由于某种原因没有加载 vc-custom-xxxx 样式:

http://dev-vrshealth.pantheonsite.io/quality-check/

我做了一些研究,唯一能找到的是特定于页面的 VC 样式不适用于 Ajax 加载的页面.但是不是通过ajax加载的.

这是 archive-quality-check.php 中的相关代码,如果您尚未选择要显示的产品批次 #,则会显示该代码:

 <?php if ($_SERVER['REQUEST_METHOD'] != 'POST'): ?><div class="col-xs-12 col-md-12" id="page-content"><?php$post_id4098 = get_post(4098);$content = $post_id4098->post_content;$content = apply_filters('the_content', $content);$content = str_replace(']]>', ']]>', $content);WPBMap::addAllMappedShortcodes();echo do_shortcode($content);?>

我觉得我一定在这里遗漏了一些东西,比如输出元数据的函数或某种类型的自定义 css,但我找不到任何解释如何做的文档.

Laurent 给出的答案对我很有用!但是我建议在你的functions.php 文件中为它创建一个函数.也许是这样的:

 function vc_custom_css($id) {$shortcodes_custom_css = get_post_meta( $id, '_wpb_shortcodes_custom_css', true );如果(!空($shortcodes_custom_css)){echo '<style type="text/css">';回声 $shortcodes_custom_css;echo '</style>';}}

然后您可以在需要时使用 vc_custom_css($yourPostID);.

When I view regular page from visual composer, it works fine like this:

http://vrshealth.com/qc2

Margins, backgrounds, etc are all working.

I needed to make a custom post type "quality-check" and am using archive-quality-check.php to display this and the vc-custom-xxxx styles are not loading for some reason:

http://dev-vrshealth.pantheonsite.io/quality-check/

I did some research and the only thing I could find is that page-specific VC styles don't work with Ajax-loaded pages. But it is not loaded through ajax.

Here is the relevant code from archive-quality-check.php which displays if you haven't already chosen a product lot # to display:

  <?php if ($_SERVER['REQUEST_METHOD'] != 'POST'): ?>

    <div class="col-xs-12 col-md-12" id="page-content">
    <?php
        $post_id4098 = get_post(4098);
        $content = $post_id4098->post_content;
        $content = apply_filters('the_content', $content);
        $content = str_replace(']]>', ']]>', $content);
        WPBMap::addAllMappedShortcodes();
        echo do_shortcode($content);
    ?>
    </div>

I feel like I must be missing something here, like a function to output metadata or some type of custom css, but I can't find any documentation which explains how.

解决方案

The answer that Laurent gave worked great for me! However I would suggest creating a function for it in your functions.php file. Maybe something like this:

  function vc_custom_css($id) {
        $shortcodes_custom_css = get_post_meta( $id, '_wpb_shortcodes_custom_css', true );
        if ( ! empty( $shortcodes_custom_css ) ) {
            echo '<style type="text/css">';
            echo $shortcodes_custom_css;
            echo '</style>';
        }
    }

Then you can just use vc_custom_css($yourPostID); whenever it is required.

这篇关于Visual Composer 未显示特定页面样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 03:02