0

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!

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
    Jun 23 '20 at 19:02
  • What are you trying to do that requires this?
    – Tom J Nowell
    Jun 23 '20 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
    Jun 23 '20 at 19:41
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.
1
  • Thank you! Yes, currently thats what I'm doing, to hard code the analytics. Just wanted to learn if there is any other way to do it by an action etc.
    – WP_Dev
    Jun 23 '20 at 19:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.