is there any way to add some php code on top in header.php file, i want to add ob_start(); function in my theme header.php file using plugin.

i used the following code but it not working

add_action( 'wp_head', function(){ 
echo "<?php ob_start(); ?>"

1 Answer 1


Looks like just syntax:

add_action( 'wp_head', function(){ 
  • This code is not working on live, only work on localhost @Aniruddha
    – Arun Kumar
    Feb 7, 2017 at 7:17
  • This is something to do with PHP settings on your live. Make sure your output buffering is on. I would suggest to go through documentation of ob_start() Feb 7, 2017 at 7:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.