Detect Visual Composer

前端 未结 4 1178
攒了一身酷
攒了一身酷 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条回答
  •  梦毁少年i
    2021-02-09 01:44

    Yes, you can detect if visual composer is enabled for a post. It's stored in the _wpb_vc_js_status post meta attribute.

    $vc_enabled = get_post_meta($post_id, '_wpb_vc_js_status', true);
    

    Note that a post can still contain the visual composer shortcodes, even when visual composer editing is not currently enabled. For example, if I setup a page with visual composer and then revert back to the normal editor, _wpb_vc_js_status will be false.

提交回复
热议问题