admin管理员组文章数量:1291051
I am using a custom WordPress theme that uses AJAX to load pages. As you can imagine this can create an instance where the site loads to a page that does not use Visual Composer (VC) and then part loads another page that does us VC, since the ready load didn't require the resources.
So far the only solutions I've thought of are using VC on every page (that doesn't work so great for Posts and custom post types) or adding a VC page to the footer (untested).
I looked deeper into the plugins code and found wp_enqueue_script()
is called across many files from what looks to be logic calling the correct extension/add-ons to VC as needed, make perfect sense.
My though is that it would be possible to use PHP to solve this issue, to call just the core requirements of VC, since no galleries or anything special will be used.
Does anyone know how to force VC to load resources to every page or have any experience with this? Thank you!
I am using a custom WordPress theme that uses AJAX to load pages. As you can imagine this can create an instance where the site loads to a page that does not use Visual Composer (VC) and then part loads another page that does us VC, since the ready load didn't require the resources.
So far the only solutions I've thought of are using VC on every page (that doesn't work so great for Posts and custom post types) or adding a VC page to the footer (untested).
I looked deeper into the plugins code and found wp_enqueue_script()
is called across many files from what looks to be logic calling the correct extension/add-ons to VC as needed, make perfect sense.
My though is that it would be possible to use PHP to solve this issue, to call just the core requirements of VC, since no galleries or anything special will be used.
Does anyone know how to force VC to load resources to every page or have any experience with this? Thank you!
Share Improve this question asked Dec 3, 2015 at 19:37 MarkMark 1351 silver badge8 bronze badges 1- Did you ever figure this out? – Mark Aroni Commented Jan 27, 2016 at 14:23
2 Answers
Reset to default 8From what you had said I realised that this needed to be called:
wp_enqueue_script( 'wpb_poser_front_js' );
wp_enqueue_style( 'js_poser_front' );
wp_enqueue_style( 'js_poser_custom_css' );
So I ended up adding something like this in functions.php in my template:
add_action( 'wp_enqueue_scripts', 'add_theme_stylesheet' );
function add_theme_stylesheet() {
wp_enqueue_script( 'wpb_poser_front_js' );
wp_enqueue_style( 'js_poser_front' );
wp_enqueue_style( 'js_poser_custom_css' );
}
WPbakery (authors of VC) explained how to do this.
You have to call a bunch of VC functions in your theme's function file, but couldn't say with absolute certainty.
I haven't tried this method (I'm using Mark Aroni's method above, because I don't need ALL VC stuff on every page, just the CSS/JS), but here's what they say...
vc_twitterBehaviour();
vc_toggleBehaviour();
vc_tabsBehaviour();
vc_accordionBehaviour();
vc_teaserGrid();
vc_carouselBehaviour();
vc_slidersBehaviour();
vc_prettyPhoto();
vc_googleplus();
vc_pinterest();
本文标签: javascriptLoad Visual Composer on Every Page (AJAX Setup)Stack Overflow
版权声明:本文标题:javascript - Load Visual Composer on Every Page (AJAX Setup) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741518344a2383030.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论