Skip to content

Fix visual composer custom css injection #35

@Plou

Description

@Plou

If we use a custom queryposts in a template, it disable Visual Composer shortcodes_custom_css injection

Until we find a better solution we nned to add this to function.php

  add_action('wp_head', array( $this, 'rand654_add_css') );

  function rand654_add_css() {
    if ( ! is_singular() ) {
        $id = get_the_ID(); // here you should change id to ID, of your post/page in loop
        if ( $id ) {
            $shortcodes_custom_css = get_post_meta( $id, '_wpb_shortcodes_custom_css', true );
            if ( ! empty( $shortcodes_custom_css ) ) {
                echo '<style type="text/css" data-type="vc_shortcodes-custom-css-'.$id.'">';
                echo $shortcodes_custom_css;
                echo '</style>';
            }
        }
    }
  }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions