Entering code in my header

How would you recommend to add a bit of code like this to the headed in PHP

/* 702330-1541992605-ai */

At the moment I just have analytics

function third_party_tracking_code_header() { ?>

<?php } add_action( 'wp_head', 'third_party_tracking_code_header' );

Hi there @VelocityWeb,

Thank you for reaching out to us. You can add the following code in your child theme’s functions.php file:

add_action('wp_head', 'custom_header_code');

function custom_header_code() {
	echo '/* 702330-1541992605-ai */';
}

You can change the above code as per your need. Please also see https://developer.wordpress.org/reference/hooks/wp_head/

Hope this helps!

Hi that caused the code to appear in the website

See top left

Hi There,

Are you sure this is your entire analytics code? /* 702330-1541992605-ai */

I believe that is just a comment and not the actual code.

You can use the same method you used for your tracking code

function custom_header_code() { ?>

<!-- YOUR CODE HERE -->

  <?php }
add_action( 'wp_head', 'custom_header_code' );

Replace the <!-- YOUR CODE HERE --> with your actual code.

Thanks,

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.