Navigation
This is archived content. Visit our new forum.
  • Author
    Posts
  • #73773

    cmwwebfx
    Participant

    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

    #73792

    Kory
    Keymaster

    Hey 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!

    #262758

    wordpressmarco
    Participant

    Dear 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,
    Marco

    #262911

    Rue Nel
    Moderator

    Hello 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.

    #263216

    wordpressmarco
    Participant

    Sorry, I meant right after the opening <body>-tag.

    #263446

    Rad
    Moderator

    Hi there,

    It should be like this,

    add_action('x_before_site_begin', 'after_body_opening');
    function after_body_opening () {
    
    }

    Hope this helps.

    #266231

    wordpressmarco
    Participant

    Great, like the solution in my post (#262758) above. Seems to work. Thanks a lot.

    #266247

    Nico
    Moderator

    Glad to hear that. You’re most welcome.

    Let us know if you need anything else.

    Thanks. Have a great day! 🙂

    #841734

    neilr2096
    Participant

    Is there an updated list please of all the Hooks within xtheme?

    #842029

    Jade
    Moderator

    Hi Niel,

    Please see this article from our Knowledge Base for the actions and filters available in X.

    Hope this helps.