Title: error when adding code tu function.php
Last modified: April 7, 2024

---

# error when adding code tu function.php

 *  Resolved [stefanocps](https://wordpress.org/support/users/stefanocps/)
 * (@stefanocps)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/error-when-adding-code-tu-function-php/)
 * Hello i need to insert code in the head section and iht body section (tracking
   google code and similar)
 * I don’t want to use a plugin and i want to write straigh tin the php file sof
   my theme
 * I have created a child theme…with child function.php
 * I have tried different tutorial form google , i set codes infunction-php but 
   the site break down
 * Any help?thanks
 * this is site info
 *     ```wp-block-code
       ` wp-core
   
       version: 6.5site_language: en_USuser_language: en_UStimezone: Europe/Romepermalink: /%postname%/https_status: truemultisite: falseuser_registration: 0blog_public: 1default_comment_status: openenvironment_type: productionuser_count: 2dotorg_communication: true wp-paths-sizes
   
       wordpress_path: /home/greenartcoin/domains/greenartcoin.eu/public_htmlwordpress_size: 123.85 MB (129862113 bytes)uploads_path: /home/greenartcoin/domains/greenartcoin.eu/public_html/wp-content/uploadsuploads_size: 160.43 MB (168221888 bytes)themes_path: /home/greenartcoin/domains/greenartcoin.eu/public_html/wp-content/themesthemes_size: 27.52 MB (28852296 bytes)plugins_path: /home/greenartcoin/domains/greenartcoin.eu/public_html/wp-content/pluginsplugins_size: 136.39 MB (143010978 bytes)database_size: 58.38 MB (61210624 bytes)total_size: 506.55 MB (531157899 bytes) wp-active-theme
   
       name: Hello Elementor Child (hello-elementor-child)version: 3.0.1.1712417703author: Elementor Teamauthor_website: https://elementor.com/?utm_source=wp-themes&utm_campaign=author-uri&utm_medium=wp-dashparent_theme: Hello Elementor (hello-elementor)theme_features: core-block-patterns, widgets-block-editor, menus, post-thumbnails, automatic-feed-links, title-tag, html5, custom-logo, editor-style, align-wide, woocommerce, wc-product-gallery-zoom, wc-product-gallery-lightbox, wc-product-gallery-slidertheme_path: /home/greenartcoin/domains/greenartcoin.eu/public_html/wp-content/themes/hello-elementor-childauto_update: Disabled wp-parent-theme
   
       name: Hello Elementor (hello-elementor)version: 3.0.1author: Elementor Teamauthor_website: https://elementor.com/?utm_source=wp-themes&utm_campaign=author-uri&utm_medium=wp-dashtheme_path: /home/greenartcoin/domains/greenartcoin.eu/public_html/wp-content/themes/hello-elementorauto_update: Disabled wp-themes-inactive (2)
   
       Astra: version: 4.6.11, author: Brainstorm Force, Auto-updates disabledKadence: version: 1.2.3, author: Kadence WP, Auto-updates disabled wp-plugins-active (9)
   
       Complianz | GDPR/CCPA Cookie Consent: version: 7.0.4, author: Really Simple Plugins, Auto-updates disabledConverter for Media: version: 5.12.3, author: matt plugins, Auto-updates disabledElementor: version: 3.20.3, author: Elementor.com, Auto-updates disabledGTranslate: version: 3.0.6, author: Translate AI Multilingual Solutions, Auto-updates disabledLiteSpeed Cache: version: 6.1, author: LiteSpeed Technologies, Auto-updates enabledSite Kit by Google: version: 1.123.1, author: Google, Auto-updates enabledWPCode Lite: version: 2.1.11, author: WPCode, Auto-updates disabledWPForms Lite: version: 1.8.7.2, author: WPForms, Auto-updates disabledWP Meta SEO: version: 4.5.11, author: JoomUnited, Auto-updates disabled wp-plugins-inactive (2)
   
       Kadence Blocks – Gutenberg Blocks for Page Builder Features: version: 3.2.33, author: Kadence WP, Auto-updates disabledVisualizer: Tables and Charts for WordPress: version: 3.10.11, author: Themeisle, Auto-updates disabled wp-media
   
       image_editor: WP_Image_Editor_Imagickimagick_module_version: 1809imagemagick_version: ImageMagick 7.1.1-19 Q16-HDRI x86_64 21601 https://imagemagick.orgimagick_version: 3.7.0file_uploads: 1post_max_size: 64Mupload_max_filesize: 64Mmax_effective_size: 64 MBmax_file_uploads: 20imagick_limits:imagick::RESOURCETYPE_AREA: 250 GBimagick::RESOURCETYPE_DISK: 9.2233720368548E+18imagick::RESOURCETYPE_FILE: 491512imagick::RESOURCETYPE_MAP: 125 GBimagick::RESOURCETYPE_MEMORY: 62 GBimagick::RESOURCETYPE_THREAD: 1imagick::RESOURCETYPE_TIME: 9.2233720368548E+18imagemagick_file_formats: 3FR, 3G2, 3GP, A, AAI, AI, APNG, ART, ARW, ASHLAR, AVI, AVIF, AVS, B, BAYER, BAYERA, BGR, BGRA, BGRO, BIE, BMP, BMP2, BMP3, BRF, C, CAL, CALS, CANVAS, CAPTION, CIN, CIP, CLIP, CMYK, CMYKA, CR2, CR3, CRW, CUBE, CUR, CUT, DATA, DCM, DCR, DCRAW, DCX, DDS, DFONT, DNG, DOT, DPX, DXT1, DXT5, EPDF, EPI, EPS, EPS2, EPS3, EPSF, EPSI, EPT, EPT2, EPT3, ERF, EXR, FARBFELD, FAX, FF, FILE, FITS, FL32, FLV, FRACTAL, FTP, FTS, FTXT, G, G3, G4, GIF, GIF87, GRADIENT, GRAY, GRAYA, GROUP4, GV, HALD, HDR, HEIC, HEIF, HISTOGRAM, HRZ, HTM, HTML, HTTP, HTTPS, ICB, ICO, ICON, IIQ, INFO, INLINE, IPL, ISOBRL, ISOBRL6, J2C, J2K, JBG, JBIG, JNG, JNX, JP2, JPC, JPE, JPEG, JPG, JPM, JPS, JPT, JSON, K, K25, KDC, LABEL, M, M2V, M4V, MAC, MAP, MASK, MAT, MATTE, MEF, MIFF, MKV, MNG, MONO, MOV, MP4, MPC, MPEG, MPG, MPO, MRW, MSL, MSVG, MTV, MVG, NEF, NRW, NULL, O, ORA, ORF, OTB, OTF, PAL, PALM, PAM, PANGO, PATTERN, PBM, PCD, PCDS, PCL, PCT, PCX, PDB, PDF, PDFA, PEF, PES, PFA, PFB, PFM, PGM, PGX, PHM, PICON, PICT, PIX, PJPEG, PLASMA, PNG, PNG00, PNG24, PNG32, PNG48, PNG64, PNG8, PNM, POCKETMOD, PPM, PS, PS2, PS3, PSB, PSD, PTIF, PWP, QOI, R, RADIAL-GRADIENT, RAF, RAS, RAW, RGB, RGB565, RGBA, RGBO, RGF, RLA, RLE, RMF, RSVG, RW2, SCR, SCREENSHOT, SCT, SFW, SGI, SHTML, SIX, SIXEL, SPARSE-COLOR, SR2, SRF, STEGANO, STRIMG, SUN, SVG, SVGZ, TEXT, TGA, THUMBNAIL, TIFF, TIFF64, TILE, TIM, TM2, TTC, TTF, TXT, UBRL, UBRL6, UIL, UYVY, VDA, VICAR, VID, VIFF, VIPS, VST, WBMP, WEBM, WEBP, WMF, WMV, WMZ, WPG, X, X3F, XBM, XC, XCF, XPM, XPS, XV, XWD, Y, YAML, YCbCr, YCbCrA, YUVgd_version: 2.3.3gd_formats: GIF, JPEG, PNG, WebP, BMP, AVIF, XPMghostscript_version: unknown wp-server
   
       server_architecture: Linux 4.18.0-477.13.1.lve.el8.x86_64 x86_64httpd_software: LiteSpeedphp_version: 8.2.16 64bitphp_sapi: litespeedmax_input_variables: 1000time_limit: 30memory_limit: 128Madmin_memory_limit: 256Mmax_input_time: 60upload_max_filesize: 64Mphp_post_max_size: 64Mcurl_version: 7.87.0 OpenSSL/1.1.1wsuhosin: falseimagick_availability: truepretty_permalinks: truehtaccess_extra_rules: truecurrent: 2024-04-07T11:09:53+00:00utc-time: Sunday, 07-Apr-24 11:09:53 UTCserver-time: 2024-04-07T13:09:51+02:00 wp-database
   
       extension: mysqliserver_version: 10.6.17-MariaDB-cll-lveclient_version: mysqlnd 8.2.16max_allowed_packet: 67108864max_connections: 151 wp-constants
   
       WP_HOME: undefinedWP_SITEURL: undefinedWP_CONTENT_DIR: /home/greenartcoin/domains/greenartcoin.eu/public_html/wp-contentWP_PLUGIN_DIR: /home/greenartcoin/domains/greenartcoin.eu/public_html/wp-content/pluginsWP_MEMORY_LIMIT: 40MWP_MAX_MEMORY_LIMIT: 256MWP_DEBUG: falseWP_DEBUG_DISPLAY: trueWP_DEBUG_LOG: falseSCRIPT_DEBUG: falseWP_CACHE: trueCONCATENATE_SCRIPTS: falseCOMPRESS_SCRIPTS: undefinedCOMPRESS_CSS: undefinedWP_ENVIRONMENT_TYPE: UndefinedWP_DEVELOPMENT_MODE: undefinedDB_CHARSET: utf8DB_COLLATE: undefined wp-filesystem
   
       wordpress: writablewp-content: writableuploads: writableplugins: writablethemes: writable google-site-kit
   
       version: 1.123.1php_version: 8.2.16wp_version: 6.5reference_url: https://www.greenartcoin.euamp_mode: nosite_status: connected-siteuser_status: authenticatedverification_status: verified-fileconnected_user_count: 1active_modules: site-verification, search-console, analytics-4, pagespeed-insightsrecoverable_modules: nonerequired_scopes:openid: ✅https://www.googleapis.com/auth/userinfo.profile: ✅https://www.googleapis.com/auth/userinfo.email: ✅https://www.googleapis.com/auth/siteverification: ✅https://www.googleapis.com/auth/webmasters: ✅https://www.googleapis.com/auth/analytics.readonly: ✅https://www.googleapis.com/auth/tagmanager.readonly: ✅capabilities:googlesitekit_authenticate: ✅googlesitekit_setup: ✅googlesitekit_view_posts_insights: ✅googlesitekit_view_dashboard: ✅googlesitekit_manage_options: ✅googlesitekit_update_plugins: ✅googlesitekit_view_splash: ✅googlesitekit_view_authenticated_dashboard: ✅googlesitekit_view_wp_dashboard_widget: ✅googlesitekit_view_admin_bar_menu: ✅googlesitekit_view_shared_dashboard: ⭕googlesitekit_read_shared_module_data::["search-console"]: ⭕googlesitekit_read_shared_module_data::["analytics-4"]: ⭕googlesitekit_read_shared_module_data::["pagespeed-insights"]: ⭕googlesitekit_manage_module_sharing_options::["search-console"]: ✅googlesitekit_manage_module_sharing_options::["analytics-4"]: ✅googlesitekit_manage_module_sharing_options::["pagespeed-insights"]: ✅googlesitekit_delegate_module_sharing_management::["search-console"]: ✅googlesitekit_delegate_module_sharing_management::["analytics-4"]: ✅googlesitekit_delegate_module_sharing_management::["pagespeed-insights"]: ⭕enabled_features:adsModule: ⭕audienceSegmentation: ⭕conversionInfra: ⭕ga4AdSenseIntegration: ⭕gm3Components: ⭕search-console_shared_roles: nonesearch-console_management: owneranalytics-4_shared_roles: noneanalytics-4_management: ownerpagespeed-insights_shared_roles: nonepagespeed-insights_management: all_adminssearch_console_property: https://www.greenartcoin.eu/analytics_4_account_id: 1957•••••analytics_4_ads_conversion_id: noneanalytics_4_property_id: 3782962••analytics_4_web_data_stream_id: 5260••••••analytics_4_measurement_id: G-CK••••••••analytics_4_use_snippet: yesanalytics_4_available_custom_dimensions: none wpforms
   
       version: 1.8.7.2lite: 5 April 2023 at 20:38upload_dir: Writabletotal_forms: 3total_submissions: 1086
       ```
   
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Ferror-when-adding-code-tu-function-php%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 9 replies - 1 through 9 (of 9 total)

 *  [Muhammad Qasim](https://wordpress.org/support/users/mqasimkh/)
 * (@mqasimkh)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/error-when-adding-code-tu-function-php/#post-17557505)
 * Hello,
 * The simplest solution is to add it in header.php and footer.php file. In **header.
   php**, you can add it before **</head>** and in **footer.php** you can add the
   footer script before **</body>**
 * However, the downside is when the theme is updated, you will need to add the 
   codes again.
 *  Thread Starter [stefanocps](https://wordpress.org/support/users/stefanocps/)
 * (@stefanocps)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/error-when-adding-code-tu-function-php/#post-17557510)
 * so this is not a solution
 * unlesss i can do that in the child header.php and footer.php
    -  This reply was modified 2 years, 2 months ago by [stefanocps](https://wordpress.org/support/users/stefanocps/).
 *  [Muhammad Qasim](https://wordpress.org/support/users/mqasimkh/)
 * (@mqasimkh)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/error-when-adding-code-tu-function-php/#post-17557521)
 * Yes you can. Created header.php file inside the child theme, copy all the code
   of header.php from parent theme and paste it in header.php in child theme. Then
   add your code before </head>. This way it won’t be affected even if you update
   theme.
 *  Thread Starter [stefanocps](https://wordpress.org/support/users/stefanocps/)
 * (@stefanocps)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/error-when-adding-code-tu-function-php/#post-17557527)
 * but if i copy ALL the code, this file will entirely replace the original header.
   php, and when th eoriginal.php will be updated..i
 * will not get update on my site?
 *  [Muhammad Qasim](https://wordpress.org/support/users/mqasimkh/)
 * (@mqasimkh)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/error-when-adding-code-tu-function-php/#post-17557704)
 * Here’s a better approach.
 * In your functions.php, add this code
 *     ```wp-block-code
       function analytics_code() {
           ?>
           add your analytics code here
           <?php
       }
       add_action('wp_head', 'analytics_code', 999);
       ```
   
 * This will add your code before </head>. The 999 priority ensure that your code
   is last thing in the <head> i.e. it will be just before </head>.
 *  Thread Starter [stefanocps](https://wordpress.org/support/users/stefanocps/)
 * (@stefanocps)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/error-when-adding-code-tu-function-php/#post-17557705)
 * ok thank you i’ll try
 * and for body?
 *  Thread Starter [stefanocps](https://wordpress.org/support/users/stefanocps/)
 * (@stefanocps)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/error-when-adding-code-tu-function-php/#post-17557715)
 * that code works! how can i check if the code for analytics, the tyag i hav set…
   are working?
 *  [Muhammad Qasim](https://wordpress.org/support/users/mqasimkh/)
 * (@mqasimkh)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/error-when-adding-code-tu-function-php/#post-17557719)
 * For body, use this:
 *     ```wp-block-code
       function body_code() {
           ?>
           add your code here
           <?php
       }
       add_action('wp_footer', 'body_code', 999);
       ```
   
 * It will add your code just before **</body>** tags. Don’t forget to replace **
   _add your code here_** with your code.
 *  Thread Starter [stefanocps](https://wordpress.org/support/users/stefanocps/)
 * (@stefanocps)
 * [2 years, 2 months ago](https://wordpress.org/support/topic/error-when-adding-code-tu-function-php/#post-17557823)
 * great, they both work. is there a way to chack that the code i have inserte dis
   really fetched?

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘error when adding code tu function.php’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 9 replies
 * 2 participants
 * Last reply from: [stefanocps](https://wordpress.org/support/users/stefanocps/)
 * Last activity: [2 years, 2 months ago](https://wordpress.org/support/topic/error-when-adding-code-tu-function-php/#post-17557823)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
