wp head - Loading a plugin in a post template without using wp_head()

I've created a custom post template for a specific purpose. Didn't include get_header() and get_footer() as I

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
Add a comment  | 

1 Answer 1

Reset to default 0

Here is some point you must understand.

  1. Monster Insights loads scripts to handle the analytics
  2. Scripts are being loaded either header or footer
  3. In order to load the scripts in your template you must include wp_head() and wp_footer()
  4. You may disable one of them by testing one by one.
  5. Another option could be hard coding analytics script in your template file. That ways you still will be able to track everything.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742324285a4422434.html

相关推荐

  • wp head - Loading a plugin in a post template without using wp_head()

    I've created a custom post template for a specific purpose. Didn't include get_header() and get_footer() as I

    7小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信