I've encountered an issue in my WordPress site's functions.php file. I added a custom function through the wp_head hook but also tried to call this function directly in another init hook, which seems to have caused the site to malfunction. Here's the code example I'm using. Can anyone advise on how to properly structure the function calls to avoid such problems? Thanks!
<?phpadd_action('wp_head', 'my_custom_function');function my_custom_function() { echo '<style> body { background-color: #000; }</style>';}add_action('init', 'my_init_function');function my_init_function() { // Error: calling function within hooks my_custom_function();}?>
I am working on the imedix.com website, and the client is not happy with the current issues. I need to resolve this as soon as possible.