1

I have a page build with Visual Composer and i want to show this page content to other page(product category), it not working.

I used code:

Vc_Manager::getInstance()->vc()->addShortcodesCustomCss($page_id);

in this solution: Visual Composer not showing specific page styles

Step 1: Build page A with id = 100

Step 2: View content of page A into page B (other page with id=105), it works well!

Step 3: View content of page A into page C (product category with term_id=30), not working, vc_custom_XXX not css output

I feel like I must be missing something here? can anyone give me some solutions. Thank

ttn_
  • 308
  • 3
  • 21

2 Answers2

0

My code, it working!

    $content = get_post($id)->post_content;
    $content_css = visual_composer()->parseShortcodesCustomCss( $content );
    if ( ! empty( $content_css ) ) { ?>
       <style type="text/css" data-type="vc_shortcodes-custom-css">
             <?php echo strip_tags( $content_css ); ?>
       </style>
    <?php }
ttn_
  • 308
  • 3
  • 21
0

It working, Good luck.

$postID = 633;
echo do_shortcode(get_post_field('post_content', $postID)); // show the_content by ID
$shortcodes_custom_css = get_post_meta( $postID, '_wpb_shortcodes_custom_css', true );

if (!empty($shortcodes_custom_css)) {
    echo '<style type="text/css">' . $shortcodes_custom_css . '</style>'; // show css in visual composer
} 
ChinhNV
  • 331
  • 2
  • 6