Child themes header?

Hi

I am following a guide from WPBeginner where i want to change the color of my web address bar by inserting this code `

They say like this " Simply add this code in your theme or child theme‘s header.php file just before the closing tag."

My issue is, that i do not have a header.php in my child themes folder/root.

I tried to copy the header.php from main x theme and insert it in the child root, but when i open this header.php file, the only text i have is this
"<?php

// =============================================================================
// HEADER.PHP
// -----------------------------------------------------------------------------
// The site header.
// =============================================================================

?>

<?php x_get_view( 'header', 'base' ); ?>"

Where is the tag??

Please advice…

Hi There,

Thanks for writing in! Please provide us with the URL to your site and let us know the changes that you required to do. So that we can assist you with a possible workaround.

Thanks!

Thanks for responding.

But I am not sure what you want the site URL for?? The question is, where is the header.php or wp.head.php as i need to enter a line of code in their so when people visit my site from mobile platform, the browser address bar will have another color than the default…

Site URL is: https://creativevfx.net

Br Hamid

Hi there,

Our theme does not have that file as there are multiple parts included by different files on the header. I suggest that you use the wp_head hook for that. Please kindly read the article below:

https://theme.co/apex/forum/t/customizations-actions-and-filters-in-x/208

You will need to have the child theme installed:

You will need to add something like this in the functions.php file of your child theme:

function third_party_tracking_code() { ?>
//ADD YOUR CODE HERE
<?php }
add_action( 'wp_head', 'third_party_tracking_code' );

Simply add your code instead of //ADD YOUR CODE HERE section.

Thank you.

Ok

I allready have the childtheme setup and using it.

And there was a function.php file in there as well.

So you say that i can simply insert this code:

And thats it??

Hi there,

Do you mean before the </head>? If so, you can simply use the wp_head action in the child theme like what @christopher.amirian suggested and place your code in //ADD YOUR CODE HERE part.

You can find more information about wp_head actio here:

https://codex.wordpress.org/Plugin_API/Action_Reference/wp_head

Hope this helps.

Thanks
So i added the code and here is how my whole functions.php looks like :slight_smile:

<?php // ============================================================================= // FUNCTIONS.PHP // ----------------------------------------------------------------------------- // Overwrite or add your own custom functions to X in this file. // ============================================================================= // ============================================================================= // TABLE OF CONTENTS // ----------------------------------------------------------------------------- // 01. Enqueue Parent Stylesheet // 02. Additional Functions // ============================================================================= // Enqueue Parent Stylesheet // ============================================================================= add_filter( 'x_enqueue_parent_stylesheet', '__return_true' ); // Additional Functions // ============================================================================= function third_party_tracking_code() { ?> <?php } add_action( 'wp_head', 'third_party_tracking_code' );

Nothing happend- Did i insert it the wromg place??

Sorry…

I masterflushed all the caches and it works perfectly. You guys rock…

Glad that we could be of a help.