1

This is about running code on wordpress . The given code runs properly outside wordpress but when I put it on theme functions file it does not do anything.

ob_start();
require('dynamic-css.php');
$content = ob_get_contents();
ob_end_clean();
$f = fopen("custom.css", "w");
fwrite($f, $content);
fclose($f);

I think I have to put this inside custom function and add hook then.

1
  • You have to understand WordPress' file structure, have a look at the get_template_directory() function, try what it produce and see how to use it. Apr 11, 2015 at 12:36

2 Answers 2

0

look a the 'Using a Hook' on here:

WP Codex

0

Atlast I found a way

add_action( 'init', 'run_this_code', 1 );
function run_this_code() {
ob_start();
require('dynamic-css.php');
$content = ob_get_contents();
ob_end_clean();
$f = fopen("custom.css", "w");
fwrite($f, $content);
fclose($f);
}

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