Ecommerce Shopify WordPress Discussion

Specify placement of PHP include at the end of the header in functions.php in WordPress

I'm using the following code to place some page-specific scripts into my header in Wordpress within functions.php. It's including the code at the beginning of the header, but it needs to be loaded last in order for the page to work as it should. Is there a way to specify in the code that I want this php file to be included at the bottom of the header? function my_post_header_function() { if( is_single() ) { include 'header-product.php'; } } add_action( 'wp_head', 'my_post_header_function' ); Note: I want it to be within the <head> </head> tags still, but placed before the closing </head> tag.
Try changing the priority to something later. The default is 10, so try 20: function my_post_header_function() { if( is_single() ) { include 'header-product.php'; } } add_action( 'wp_head', 'my_post_header_function', 20 );

January 27, 2024

Due to the limitations of placement in functions.php I instead placed it within header.php before the closing </head> tag, as follows: <?php if( is_single() ) { include 'header-product.php'; } else {} ?>

January 27, 2024

TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.