-
AuthorPosts
-
July 26, 2014 at 12:06 pm #73773
Hi there
We are finishing up a plugin that is supporting some of the big frameworks and are going to offer support for a few select themes on ThemeForest. X is one of the ones we are going to support.in order for us to add support, please could you provide a list of action hooks the X theme uses.
– Ciaran
July 26, 2014 at 3:24 pm #73792Hey Ciaran,
Thanks for writing in! We have only just begun to start adding in action hooks throughout X’s templates in an effort to make modifications easier for certain actions. At this time, this is the list of hooks available:
- ‘x_before_site_begin’ – Fires before the opening of the .site element.
- ‘x_after_site_begin’ – Fires after the opening of the .site element.
- ‘x_before_site_end’ – Fires before the closing of the .site element.
- ‘x_after_site_end’ – Fires after the closing of the .site element.
- ‘x_before_view_’ . $file – Fires at the beginning of a View. The $file variable is the location and name of the View without the file extension. For instance, if you wanted to fire something before the content-page.php View for Integrity, the hook would be ‘x_before_view_integrity-content-page’. It should be noted that these hooks in particular are something that might be altered in the future, so be careful when using them as they might be changed or deprecated depending on how we want to manage things.
- ‘x_after_view_’ . $file – Similar to the previously mentioned hook, but fires at the end of a View instead.
We plan on adding more hooks with each release in an effort to make development and alterations easier for our users as well as providing a new resource in the Knowledge Base that will keep track of all of this, so make sure to keep checking back there in the future for up to date information on this matter.
Thanks!
April 30, 2015 at 9:25 pm #262758Dear stuff and forum,
can anyone tell me how to use the hook ‘x_before_site_begin’ for implementing the Google Tag Manager Tracking Snippet with my child theme’s functions.php right after the opening <head>?
May it work like this:
function gtm_tracking_code() { ?> <!-- Google Tag Manager --> <noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-XXXXX" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= '//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-PVTM2B');</script> <!-- End Google Tag Manager --> <?php } add_action( 'x_before_site_begin', 'gtm_tracking_code' );
Thank you,
MarcoMay 1, 2015 at 3:17 am #262911Hello There,
Thanks for posting in!
If you want to insert something inside <head> </head> tag in your, you will use the wp_head hook. Our hook x_before_site_begin is triggered after the body element. Your code will probably be like this:
function gtm_tracking_code() { ?> <!-- Google Tag Manager --> <noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-XXXXX" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= '//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','GTM-PVTM2B');</script> <!-- End Google Tag Manager --> <?php } add_action( 'wp_head', 'gtm_tracking_code' );
Hope this helps. Kindly let us know.
May 1, 2015 at 12:58 pm #263216Sorry, I meant right after the opening <body>-tag.
May 1, 2015 at 8:06 pm #263446Hi there,
It should be like this,
add_action('x_before_site_begin', 'after_body_opening'); function after_body_opening () { }
Hope this helps.
May 5, 2015 at 1:32 pm #266231Great, like the solution in my post (#262758) above. Seems to work. Thanks a lot.
May 5, 2015 at 1:52 pm #266247Glad to hear that. You’re most welcome.
Let us know if you need anything else.
Thanks. Have a great day! 🙂
March 17, 2016 at 9:03 am #841734Is there an updated list please of all the Hooks within xtheme?
March 17, 2016 at 3:21 pm #842029Hi Niel,
Please see this article from our Knowledge Base for the actions and filters available in X.
Hope this helps.
-
AuthorPosts