If you want to add headers this can only be done before you are returning data. Headers are send at the start of a response from the browser.
What probably goes wrong is that you have an empty line on the top of your file. Or you do somewhere an echo
(or something a like). Then PHP starts outputting data (thus returning stuff to the browser). Then you’ve missed your change of adding headers.
Please check if you don’t have an empty line in your file like this:
.empty first line or any char here.
<?php
echo 'hi'; // Echo here BEFORE your setting any headers
?>
.or an empty line/char here?
Related Posts:
- How to detect WP plugins used on a site
- Using WordPress as a CMS: Developer preferences for custom vs existing plugins
- Login with OpenID, similar to Stack Exchange sites?
- Preserve custom URL parameter on more pages
- Does WordPress contain “default” anti-SQL injection code that responds with a 404 error?
- WordPress Capabilities: edit_user vs edit_users
- Passing .pem and .key files in cURL doesn’t work in WordPress
- Is there a limit on the size of a WP page?
- How to restrict Front-End Editor on a page?
- How do I create a custom wordpress slideshow plugin?
- Is there a WordPress Plugin that allows voting “does this coupon work” on specific links like Retailmenot
- Advanced custom field plugin not showing in admin sidebar
- How to remove action from plugin?
- Sidebar Generator issue [closed]
- Force plugin to fail activation
- Is there a plugin to help with translation of other plugins? [closed]
- How to load default scripts included with WordPress correctly?
- Skip file when plugin updated
- Are contributed plugin translations automatically installed in WordPress?
- Why would WP-CLI and WP Admin show different list of plugins with updates?
- Can I use a Shortcode output as an HTML attribute value?
- Use WordPress with a custom OAuth2 provider
- Translating plugin inside the theme [closed]
- Is license need for free wordpress plugin
- How to send little data between admin pages of my plugin?
- How to activate plugins for my WordPress sites from a remote server
- Register script in one plugin, and enqueue it in another
- how to load the language file in plugin?
- Getting a List of Categories for Use in a Plugin?
- Add a captcha form to the woocommerce register form
- WordPress multiple pages on one page via button switching
- How to get all of the activate_plugin action parameters?
- Redirect already logged in users away from a page to a specific page base on user role
- What can be reason for no plugin-strings available under stable section on translate.wordpress.org?
- WP_Terms_List_Table Quick Edit not working
- External Script Using WP – Hooks / Actions Not Working?
- How to add FB like + share AND also other Social Buttons on ALL pages and posts?
- file-gallery plugin line 1573 broken in 4.2 upgrade [closed]
- How do I use wp_editor() in widget form?
- the_tags : can we insert a class
- PHP Error When a plugin is active
- Errors when trying to use a plugin to write to the database
- Completely disabling password reset/recovery
- How to load different homepage on Mobile.?
- WordPress REST API Plugin Development – Add Custom Endpoint
- how to prevent all css and javascripts files from loading
- Hook into the rendering of a WordPress Template
- Best way to count visitors?
- WPTouch – how to remove shortcodes or make shortcodes function
- Adding class to last list item? Not WP generated
- I changed .live() to .on() but change is not reflected on the server
- Trying to add a page template for my custom post type from a plugin, but it will not display in the template dropdown unless file is in theme
- Custom shortcode for displaying user based on a role parameter
- How do I set up XAMPP to allow me to download plugins and themes?
- WP-API Custom Post Type json_no_route
- Select Form Element Not Saving from Plugin Options
- Cannot access WP admin because plugin returns 204
- My widget won’t update its values when save is clicked
- Install old version of plugin from admin panel?
- Extend a plugin to include a widget option
- Can we give Pending as a Role to wp_insert_user?
- Is the Block Bad Queries Plugin Still Relevant?
- Table of contents (TOC) plugin is not showing header tag
- Is it possible to restore a deleted WordPress plugin I deleted from WordPress admin menu?
- Custom page from wp admin area
- Unexpected add action function in WP plugin
- I’m receiving the following error using the below code: Uncaught Error: Cannot use object of type WP_REST_Response as array
- how to display data from user panel using cmb2 metabox?
- WooCommerce Product Table – filter query on attributes
- PDF Viewer Origin is Different
- WordPress Sumo Plugin not showing all images on clicking pinterest icon
- WP nonce verification
- Enable a Coming Soon Page while the rest of the site is accessible
- Call to undefined function add_action() in plugin
- Create Custom Single Page Link foreach custom Database table results id
- Integrating the Office 365 and/or Windows Live credentials in to our website like FB and Twitter
- How to Display image from Menu Image in Walker Dropdown Select Menu
- How to add separator between default and custom panels in WordPress customizer?
- Clone a Post Tite and Custom Field into Custom Post type
- How to replace native comment_count with Comments Evolved aggregate count
- Having trouble going from Jfiddle to implementing in WordPress :(
- Buddypress Member list not showing admin and mods
- wordpress Shortocode running twice?
- Shortcode in a blog post, footer and related products stop working
- SVN problem – commit taking forever to fix incomplete prior commit
- pluggable function in theme, to be overridden by plugin
- Plugin: Unable to Save the Image Alignment Option to Display in the Widget in the Sidebar
- Remove action plugin
- Plugin used only on some pages – not widget
- Conditional statements using category and Tags
- Issue with custom plugin
- How to link that “logged in” in “you must be logged in to post a comment” with custom login page on WordPress?
- Get value of a key from a Plugin Serialized array
- How to make temporary expiring link for a downloadable file
- Add country flags
- How to declare this function correctly?
- Content expands beyond its column container [closed]
- Plugin version number after code rewrite [closed]
- Problems with file_exists() with metabox plugin in WordPress
- How to rewrite URL using .htaccess in WordPress Plugin