admin管理员组文章数量:1333395
I've created a custom post template for a specific purpose. Didn't include get_header()
and get_footer()
as I only wanted a blank template.
Problem is: I want to load monster insights plugin.
Adding wp_head
and then removing the unwanted parts seems a long route and still, there are elements I wasn't able to remove, so looking for a simpler approach by just skipping the get_header and only include the plugin that I need on that post template.
Thank you!
I've created a custom post template for a specific purpose. Didn't include get_header()
and get_footer()
as I only wanted a blank template.
Problem is: I want to load monster insights plugin.
Adding wp_head
and then removing the unwanted parts seems a long route and still, there are elements I wasn't able to remove, so looking for a simpler approach by just skipping the get_header and only include the plugin that I need on that post template.
Thank you!
Share Improve this question edited Jun 23, 2020 at 18:06 Mort 1305 9835 silver badges18 bronze badges asked Jun 23, 2020 at 17:21 WP_DevWP_Dev 1 3- Plugins aren't sandboxed in any way, once WP gets to the template part all the plugins are already loaded, and their code isn't separated from eachother. It's like taking 5 boxes of grain and dumping it all in a mixer, you can't pick and choose unless it's a specific hook or example. Even then, by the time it's deciding which template to load it's too late to most of that – Tom J Nowell ♦ Commented Jun 23, 2020 at 19:02
- What are you trying to do that requires this? – Tom J Nowell ♦ Commented Jun 23, 2020 at 19:03
- In the custom template, I do not want any stylesheet or script that I add myself. The template needs to be a simple <html><head></head><body><body></html>. In <head> only monster insights. Why someone would want that? tbh, I have no idea. Its for someone (will ask though). After trying hours and hours of manually dequeuing and deregistering stylesheets... there were still some that I couldn't so thought of just not using the get_header at all. – WP_Dev Commented Jun 23, 2020 at 19:41
1 Answer
Reset to default 0Here is some point you must understand.
- Monster Insights loads scripts to handle the analytics
- Scripts are being loaded either header or footer
- In order to load the scripts in your template you must include
wp_head()
andwp_footer()
- You may disable one of them by testing one by one.
- Another option could be hard coding analytics script in your template file. That ways you still will be able to track everything.
本文标签: wp headLoading a plugin in a post template without using wphead()
版权声明:本文标题:wp head - Loading a plugin in a post template without using wp_head() 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742324284a2453412.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论