The functions.php
is loaded before WordPress has sent the HTTP response headers. If you have raw HTML content in that file, even a HTML comment, then that will be sent immediately, triggering PHP’s built-in HTTP headers.
Now, WordPress doesn’t know about this and tries to send the headers as usual. And that will cause an error message like “Headers already sent …”. This message comes with information about the file and line that created the first output, so it’s rather easy to debug.
Long story short: Don’t create raw output in the functions.php
, use template files for that.
Related Posts:
- How do I change/modify the_post_thumbnail(); html output?
- start_lvl Ignored in Custom walker_nav_menu
- Modify previous and next text from pagination links
- Calling a method from functions.php on a click of a button
- HTML table from shortcode with multiple parameters
- Placing raw HTML inside a WordPress shortcode
- Slide in Panel WordPress Post
- Shortcode content output but not in correct place
- Add itemprop Schema.org Markup to li Elements in wp_nav_menu
- Removing unneccessary p-tags (Not every p)
- Add a class to the anchor tag on HTML5 gallery
- Where in PHP do I move title and meta (date) to bottom of each blog section?
- Converting HTML Template to WordPress Theme
- Populate dropdown with Child Pages based on Parent Page chosen
- How to store data from multiple forms using ajax and php
- Use DOMDocument with ob_start breaks my HTML code
- Add .htm extention to a custom taxonomy
- Noscript not working as it should in wordpress site
- How to make modifications only to certain elements of an HTML string on the server-side?
- Widget back end radio button issue
- Adding function to child theme’s function.php
- How to use the checked() function to check for a non-empty var
- Calling function in loop causes repeat data
- How can I use custom menus with a Bootstrap WordPress theme?
- Time Delay a URL Redirect for Specific Page
- how to changes mobile menu toggle breakpoint in WordPress
- WordPress User Meta value variable into Google Gauge Chart
- Adding HTML Code to Replace Text in PHP
- PHP function for horizontal Woocommerce thumbnails and badges
- How to use data URL in WordPress?
- Remove span tags from WooCommerce Downloads page
- How to center all text body in single.php at once?
- How can I get my pagination loop to display the correct number of total pages?
- Can’t get_users info by using json_encode
- Show post/page into div using function
- WordPress HTML Helper
- Cant get theme to change footer color through theme customizer
- Sorting Problem
- Add multiple HTML attributes to an Elementor button
- Hide old attachments from wp media library
- PHP – redirect https to http and www to non-www
- How to overwrite youtube embed?
- Need to get specific data from array
- Generating add_settings_section() calls dynamically
- Sort registered users by post count? (inside admin dashboard)
- How to change a public function inside a class of a plugin?
- How to get the POST TITLE using the POST ID?
- WooCommerce – Reset quantity input field when variation changes
- Query all posts of a custom taxonomy term
- Trying to establish connection to External Database
- Load a page into a div with Ajax
- Login/logout in header
- Error when adding excerpt to the content through functions.php
- Add data attribute to each li in menu
- How to abort saving data in save_extra_profile_fields function WordPress?
- Get the date of the className or classID
- Way to add captions to gallery images by code
- My custom get_the_excerpt() can’t get excerpt by ID
- WordPress Options Page Theory Question
- How to make container class in PHP
- How do I check or test a WordPress Auto Year Change Script?
- Prevent redirect to wp-login.php
- How to hide the author box of a specific user?
- Find out last 7 days of upload images, last week uploaded image from Gallery and display them in different pages
- Add date before entry title in Twenty Twelve
- WordPress theme showing blank page
- Defining multiple categories for showing latest posts
- Pagination Not Working (pages duplicating content)
- Custom functions for string data calculations
- How are these PHP functions applied to a specific page in WordPress?
- The additional fee for the COD payment method not visible in the front-end
- “pre_get_posts” orderby custom date field in different format?
- Reliable way to add nonce to HTTP Header in WordPress?
- Trying to update Woocommerce meta values
- How to add and subtract user meta values after post meta update
- Custom global variable not working in function
- dynamic php menu with hidden sub-categories only showing when the category name is clicked
- couldnt show short code atts in category
- Embed video from streamtape using direct link
- get_the_author_meta( ‘ID’ ) just return 1
- Enqueue sripts and styles only if function is called
- Site title not showing. Please help me
- Check if post visited first time
- Store custom field’s multiple values in one user meta key
- WooCommerce multiple custom fields code
- Target a specific container to style on WordPress storefront theme
- Need to Echo A Url path to show on a wordpress page
- Theme editing “post thumbnail” help
- Pass form attributes to another php template in wordpress
- Restrict File Type Uploads by User on Wordress via functions.php
- How to Request a User to Register on Landing at a Site, Then Automatically Delete the Users Password on Logout?
- AJAX Returning Way Too Many Posts
- How to get category pages to look like a certain archive page?
- How to call a specific value within the functions.php file?
- Select area and checkbox data is not saving?
- How to modify this function to exclude also the post belonging to a specific category?
- Suppress errors when using global function
- Hide category by tag
- add_rewrite_rule image from /images/site2/favicon.ico to /favico.ico
- Background Tasks in a WP Cronjob?