Detect Visual Composer

前端 未结 4 1162
攒了一身酷
攒了一身酷 2021-02-09 01:08

Is there a way to detect if a WordPress page is using Visual Composer?

I have 2 different page templates:

  1. Default template for regular pages.
  2. Temp
4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-09 01:39

    Actually _wpb_vc_js_status since 4.8 is not correct, because it was not used anymore. The simplest way to check if page is using visual composer - it is check for vc_row shortcode in content.

    $post = get_post();
    if ( $post && preg_match( '/vc_row/', $post->post_content ) ) {
        // Visual composer works on current page/post
    }
    

提交回复
热议问题