Support » Plugin: Blank Slate » Adding PHP Snippet to Template

  • Resolved jcpacelli

    (@jcpacelli)


    i see that i can add my GTM code to the blank-slate-template.php file in the plugins folder but can i override this template file so i dont need to re-input the code if/when the Blank Slate plugin updates?

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Micah Wood

    (@wpscholar)

    @jcpacelli As a best practice, you shouldn’t hardcode your Google Tag Manager code into your theme or other page templates. Instead, I’d recommend installing the Google Site Kit plugin (https://wordpress.org/plugins/google-site-kit/) and configuring Google Tag Manager through that. This will allow your code to be automatically applied to any WordPress theme or page template.

    Google Site Kit has its limitations as well so i have stopped using it. I have not seen that hardcoding the GTM is against best practices. I believe Site Kit is fairly new (< 1 year old?) and from what I have seen is best used for a brief, yet consolidated, view of site data.

    Plugin Author Micah Wood

    (@wpscholar)

    @jcpacelli The issue with hardcoding is that if you edit a third-party theme directly, then those changes are lost the next time the theme is updated. If you hardcode in a child theme, then your GTM code is lost if you ever change themes. This is why utilizing a plugin for this is ideal. Plugins can hook into WordPress and properly load your GTM code in a variety of contexts.

    While The Site Kit plugin is fairly new, it is maintained by the Google team directly. It can display some site data/stats in the WordPress admin area, but its key function is to actually output Google Analytics and/or Google Tag Manager code for data collection.

    • This reply was modified 3 months, 1 week ago by Micah Wood.

    Thank you but I know what I am doing regarding my theme and plugin setup. I know what happens if I change themes or update plugins. I know what a child theme is used for and how they work and I am not installing Site Kit again.

    Your first sentence is why I opening this thread to begin with because I am fully aware of what happens when a plugin (or theme) is updated. I can edit the blank slate template every time it is updated as a last resort.

    I am wondering if it is possible with your plugin to override that template like you can with WooCommerce, for example. Duplicating the PHP file and placing it in my child theme (which I know will be replaced if I change themes, which I have no plans to do in the foreseeable future) in the directory of /childtheme/blank-slate/ does not override the plugin’s default file.

    jcpacelli

    (@jcpacelli)

    I am still curious if this is possible with your plugin.

    Plugin Author Micah Wood

    (@wpscholar)

    @jcpacelli At the moment, there is no way to just drop a file in a theme and have it override the existing templates in the plugin. However, there is a blank_slate_templates filter that you can use to accomplish the same thing.

    https://plugins.trac.wordpress.org/browser/blank-slate/tags/1.1.5/functions.php#L65

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.