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.