Support » Plugin: Content Blocks (Custom Post Widget) » Visual Composer / WP Bakery custom CSS styles

  • In the provided shortcode (content_block) and widget (custom_post_widget), WPBakery styles are not being loaded. Please consider incorporating the following code, which will load the CSS specific to a content section or at least provide an action hook that passes in the post ID.

    // Load custom CSS from meta data
    $shortcodes_custom_css = get_post_meta($post->ID, ‘_wpb_shortcodes_custom_css’, true);

    // If custom CSS is provided, load inline style.
    if (!empty($shortcodes_custom_css))
    {
    $shortcodes_custom_css = strip_tags($shortcodes_custom_css);
    echo ‘<style type=”text/css” data-type=”vc_shortcodes-custom-css”>’;
    echo $shortcodes_custom_css;
    echo ‘</style>’;
    }

    Kudos to this StackOverflow user for this code. https://stackoverflow.com/a/48914309/7031135

Viewing 1 replies (of 1 total)
  • George

    (@subscriptiongroup)

    The postmeta name has been updated by WPBakery on their latest version (v5.7) to _wpb_post_custom_css so this code won’t work any more.

    This change is not documented on their changelog but the code should be updated to

    // Load custom CSS from meta data
    $shortcodes_custom_css = get_post_meta($post->ID, '_wpb_post_custom_css', true);
    
    // If custom CSS is provided, load inline style.
    if (!empty($shortcodes_custom_css))
    {
    $shortcodes_custom_css = strip_tags($shortcodes_custom_css);
    echo '<style type="text/css" data-type="vc_shortcodes-custom-css">';
    echo $shortcodes_custom_css;
    echo '</style>';
    }
    • This reply was modified 11 months, 1 week ago by George.
Viewing 1 replies (of 1 total)
  • The topic ‘Visual Composer / WP Bakery custom CSS styles’ is closed to new replies.