Home › Forums › Backend Issues (wp-admin) › my_acf_admin_head errors
I’ve implemented my_acf_admin_head in order to give users the ability to add a global background image to the website. I’ve added the codebelow to my functions.php.
I have wp-config in debug mode. It is kicking a bunch of warning errors when I log in or out of wordpress.
Here is the error log…
Warning: Cannot modify header information - headers already sent by (output started at /Users/robertrhu/Documents/Websites/vail/wp-content/themes/thisisepic/library/user-styles.php:2) in /Users/robertrhu/Documents/Websites/vail/wp-login.php on line 402
Warning: Cannot modify header information - headers already sent by (output started at /Users/robertrhu/Documents/Websites/vail/wp-content/themes/thisisepic/library/user-styles.php:2) in /Users/robertrhu/Documents/Websites/vail/wp-login.php on line 415
Warning: Cannot modify header information - headers already sent by (output started at /Users/robertrhu/Documents/Websites/vail/wp-content/themes/thisisepic/library/user-styles.php:2) in /Users/robertrhu/Documents/Websites/vail/wp-includes/pluggable.php on line 914
Warning: Cannot modify header information - headers already sent by (output started at /Users/robertrhu/Documents/Websites/vail/wp-content/themes/thisisepic/library/user-styles.php:2) in /Users/robertrhu/Documents/Websites/vail/wp-includes/pluggable.php on line 915
Warning: Cannot modify header information - headers already sent by (output started at /Users/robertrhu/Documents/Websites/vail/wp-content/themes/thisisepic/library/user-styles.php:2) in /Users/robertrhu/Documents/Websites/vail/wp-includes/pluggable.php on line 916
Warning: Cannot modify header information - headers already sent by (output started at /Users/robertrhu/Documents/Websites/vail/wp-content/themes/thisisepic/library/user-styles.php:2) in /Users/robertrhu/Documents/Websites/vail/wp-includes/pluggable.php on line 917
Warning: Cannot modify header information - headers already sent by (output started at /Users/robertrhu/Documents/Websites/vail/wp-content/themes/thisisepic/library/user-styles.php:2) in /Users/robertrhu/Documents/Websites/vail/wp-includes/pluggable.php on line 918
Warning: Cannot modify header information - headers already sent by (output started at /Users/robertrhu/Documents/Websites/vail/wp-content/themes/thisisepic/library/user-styles.php:2) in /Users/robertrhu/Documents/Websites/vail/wp-includes/pluggable.php on line 919
Warning: Cannot modify header information - headers already sent by (output started at /Users/robertrhu/Documents/Websites/vail/wp-content/themes/thisisepic/library/user-styles.php:2) in /Users/robertrhu/Documents/Websites/vail/wp-includes/pluggable.php on line 922
Warning: Cannot modify header information - headers already sent by (output started at /Users/robertrhu/Documents/Websites/vail/wp-content/themes/thisisepic/library/user-styles.php:2) in /Users/robertrhu/Documents/Websites/vail/wp-includes/pluggable.php on line 923
Warning: Cannot modify header information - headers already sent by (output started at /Users/robertrhu/Documents/Websites/vail/wp-content/themes/thisisepic/library/user-styles.php:2) in /Users/robertrhu/Documents/Websites/vail/wp-includes/pluggable.php on line 924
Warning: Cannot modify header information - headers already sent by (output started at /Users/robertrhu/Documents/Websites/vail/wp-content/themes/thisisepic/library/user-styles.php:2) in /Users/robertrhu/Documents/Websites/vail/wp-includes/pluggable.php on line 925
Warning: Cannot modify header information - headers already sent by (output started at /Users/robertrhu/Documents/Websites/vail/wp-content/themes/thisisepic/library/user-styles.php:2) in /Users/robertrhu/Documents/Websites/vail/wp-includes/pluggable.php on line 928
Warning: Cannot modify header information - headers already sent by (output started at /Users/robertrhu/Documents/Websites/vail/wp-content/themes/thisisepic/library/user-styles.php:2) in /Users/robertrhu/Documents/Websites/vail/wp-includes/pluggable.php on line 929
Warning: Cannot modify header information - headers already sent by (output started at /Users/robertrhu/Documents/Websites/vail/wp-content/themes/thisisepic/library/user-styles.php:2) in /Users/robertrhu/Documents/Websites/vail/wp-includes/pluggable.php on line 930
Warning: Cannot modify header information - headers already sent by (output started at /Users/robertrhu/Documents/Websites/vail/wp-content/themes/thisisepic/library/user-styles.php:2) in /Users/robertrhu/Documents/Websites/vail/wp-includes/pluggable.php on line 931
Warning: Cannot modify header information - headers already sent by (output started at /Users/robertrhu/Documents/Websites/vail/wp-content/themes/thisisepic/library/user-styles.php:2) in /Users/robertrhu/Documents/Websites/vail/wp-includes/pluggable.php on line 1174
Here is the code
<!--USER INPUT STYLES FUNCTION-->
<?php function my_acf_admin_head() {
$backgroundimage = get_field('background_image', 'option');
?>
<!--BEGIN USER INPUT STYLES-->
<style type="text/css">
/**Adds custom global background image**/
.main-content {
background-image: url(<?php echo $backgroundimage; ?>);
}
</style>
<?php
}
add_action('wp_head', 'my_acf_admin_head');
?>
<!--END USER INPUT STYLES-->
Figures it out. It was the spaces in my_acf_admin_head. Cleaned it up like this…
<?php function my_acf_admin_head() {
$backgroundimage = get_field('background_image', 'option'); ?>
<!--BEGIN USER INPUT STYLES-->
<style type="text/css">
/**Adds custom global background image**/
.main-content {
background-image: url(<?php echo $backgroundimage; ?>);
}
</style>
<?php } add_action('wp_head', 'my_acf_admin_head'); ?>
The topic ‘my_acf_admin_head errors’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.