Questions tagged [headers]
HTTP headers are what is sent to the browser before the page markup. They often include the page MIME type, charset, status code and encoding. Headers are often overridden to change the page MIME type or redirect the user.
578
questions
36
votes
5answers
34k views
Why won't wp_mail() let me set the From: header when plain old PHP mail() will?
When I use wp_mail( $to, $subject, $message, $headers ) (with values in place, of course), the email gets sent with a from name and email that isn't set anywhere I can find (not even in PHP or Apache ...
22
votes
3answers
73k views
How to add code to Header.php in a child theme?
I'm creating a child theme for the first time and I had a few questions regarding code added to header.
In a non child theme there is certain code I add to my header.php file such as google ...
18
votes
4answers
15k views
WP function/filter for modifying http headers?
Is there a dedicated WP function, action or filter to use when adding/modifying the HTTP headers?
For now I just hook a PHP header() call into the WP 'init' hook like this:
add_action('init', '...
15
votes
10answers
29k views
WordPress Plugin Development - Headers Already Sent Message
I'm developing WordPress plugins. When I activate my plugin, I'm getting the following message:
The plugin generated 293 characters of
unexpected output during activation.
If you notice “...
13
votes
4answers
5k views
How does one suppress a 404 status code in a WordPress page?
I've got a WordPress site that includes pages pulled from a different database. The problem is that these other pages return a 404 status code. (The WordPress posts/pages are fine.)
The 404'ed pages ...
13
votes
2answers
40k views
Why is there a link tag with rel “profile” pointing to gmpg.org?
I found this <link rel="profile" href="http://gmpg.org/xfn/11"> in header.php file of WordPress theme. What will happen if I don't use this? What will happen if I use this ?
11
votes
4answers
35k views
wp_redirect() - headers already sent
I am trying to use wp_redirect() to redirect the user after successfully submitting a signup form on the page.
It's not working and shows the following error:
Warning: Cannot modify header ...
11
votes
1answer
5k views
wp_headers vs send_headers. When to use each?
I've seen wp_headers and send_headers both used before for the same thing and I'm wondering how you're suppose to know which one to use and when...
On the send_headers codex page there's an example ...
10
votes
8answers
29k views
Admin bar and fixed header issue?
I've styled my header to have a fixed top position. While logged in to wordpress, the wp admin nav bar covers the top section of my header making imposible to access my top navigation. I would like ...
9
votes
1answer
7k views
How to remove rest api link: in http headers?
i would like to remove the "link:" line added to the http headers since wordpress 4.4
here is a
curl -I killcandida.org
here is the output extract of the line that i would like to delete:
Link: &...
8
votes
2answers
4k views
Why is wp_redirect() preferable to a standard PHP header redirect?
In asking a question about hooks and redirects, I was advised to use wp_redirect in place of the PHP header function. Just wondering why wp_redirect is preferable?
7
votes
2answers
7k views
Disable h1 and h2 from rich text editor combobox
In the Wordpress control panel, when writing a new post, I would like to disable the Header 1 and Header 2 from the text formatting combobox, because I already use them on my theme (h1 for blog name ...
7
votes
4answers
33k views
Is there a way to enable Cross-Origin Resource Sharing for WordPress' ajaxurl?
WordPress already has a default URL for jQuery-WordPress application calls and it's well known as the ajaxurl. However, there are cases wherein one would need to enable Cross-Origin Resource Sharing (...
7
votes
2answers
2k views
Auto get_header and get_footer on every template?
Is there a way to automatically run get_header() at the beginning of template and get_footer() at the end of it?
Currently my code is too repetitive with those calls.
I've been looking for a way to ...
7
votes
1answer
12k views
disable wordpress canonical tag meta
wordpress core automatically generates canonical tag in HEAD section:
<link rel="canonical" href="http://blabla.com" />
how to disable/remove that?
7
votes
1answer
28k views
How do I add a search bar to my header?
I need to add a functioning search bar to my header. I have read through the forums but am unsure what code I need to put where. For instance, where do I put the css code versus where do I put the ...
7
votes
3answers
4k views
External page integrated into WordPress returns a 404 error
I have a script that I'd like to call via AJAX from my WordPress theme, it relies upon some core WordPress functions so I am including WordPress blog header like so:
define( 'WP_USE_THEMES', false );
...
7
votes
3answers
12k views
How do I force wp_enqueue_scripts to load at the END of <head>?
I am loading scripts via wp_enqueue_scripts in my child theme.
The only problem is that my style.css script get loaded BEFORE plugin scripts, yet I need to override the CSS in the plugins with my ...
6
votes
3answers
285k views
Can't get a JSON object in response to an Ajax request with wp_ajax
I have a problem with WordPress and Ajax.
This is my JavaScript part (I trimmed it a bit):
var posts = $.ajax({
type: 'POST',
url: ajaxurl,
async: false,
dataType: 'json',
data: {...
6
votes
2answers
42k views
Where is get_header('shop') file in Woocommerce templates
I need to modify the get_header('shop') file in Woocommerce but don't know where it's located, if someone knows please help me out - thanks!
6
votes
7answers
18k views
Add header and footer to WP backend
I want to add a header in the backstage in order to look more blend in like the frontend. Nothing much I want to add, just the header and footer is enough. The content section remains the original ...
6
votes
3answers
11k views
Adding rel=“next” & rel=“prev” for paginated archives
Does someone perhaps know a plugin or snippet (besides Yoast's WordPress SEO) to accomplish this perhaps? Pagination with rel=“next” and rel=“prev”
The only thing I've come across seems to be an 3-...
6
votes
3answers
2k views
Math notation on WordPress.com?
I am a new user with WordPress, and I would like to use mathematical formulas. I have been reading the mathjax pages for hours, such as this one and quite a few others. This may be a bad question, ...
5
votes
1answer
4k views
Recommended location to set response headers?
I'm looking to set an Expires response header for all page requests. I see the doctype in the theme's header.php file, so I'm guessing I could set it right before that line, but I'm wondering if there ...
5
votes
2answers
19k views
Adding javascript to child theme
I want to apply some javascript to my header and want to know what the best way to implement it is.
here is the source that contains the javascript I'm including - https://codepen.io/kaemak/pen/mHyKa/...
5
votes
2answers
16k views
How to prevent wordpress from loading old versions of jquery in wp_head();?
I noticed my twenty twelve theme is including outdated versions of jquery and js so I want to replace the scripts with the newer versions, however the scripts are in the file included by wp_head() (...
5
votes
5answers
14k views
How do I make my plugin load before the headers are output so I can redirect wordpress?
I wrote some code, that helps secure my clients files, and added it to wordpresses function file. however, whenever updates come in, it obviously overwrites my function.
So I wanted to create it as a ...
5
votes
2answers
20k views
Is it safe to fix Access-Control-Allow-Origin (CORS origin) errors with a php header directive?
I am trying to show a Formidable Pro Form from a WordPress site to the other.
I followed the developer's API and the REST API, but faced a CORS problem.
Then I found a suggestion on a forum thread ...
5
votes
3answers
7k views
How to set custom cookies before output
What's a surefire way to check/set cookies before the php headers are sent? Is there an action or filter that would be the best place to hook a setcookie() function?
4
votes
2answers
1k views
Loading different JS for http and https
I'm using a third party JS file. And they have both http and https version.
My site have some pages loading in https while most of pages are in http.
Now my question is could I do something in header....
4
votes
1answer
6k views
Custom endpoint and X-WP-TotalPages (headers)
I have a custom endpoint defined like so:
add_action( 'rest_api_init', function () {
register_rest_route( 'menc/v1', '/crosscat/(?P<dept>[\w-]+)/(?P<cat>[\w-]+)', array(
...
4
votes
3answers
2k views
Hook for URL Request
I would like to make XML files downloadable, instead of allowing the browser to displaying them inline.
I know I can use the Content-Disposition: attachment HTTP header (of course, better solutions ...
4
votes
1answer
3k views
Getting “Cannot modify header information - headers already sent” error on wp-admin only whenever any plugin is activated
I had this problem in this question and tried to isolate where the issue is coming from, but I am only more confused now.
I'm trying to upgrade my site from the current WordPress 4.5.5. , but first, ...
4
votes
0answers
163 views
Additional Option on Custom Header admin
I would like to extend the Custom Header class to include an animation feature for the header graphics. Essentially, I'd like to add another possible value for the radio button for randomization. The ...
3
votes
5answers
14k views
Add code into <head> on a per page/post basis
Is there plugin (or an easyish way) to add code to the <head> section on a per page/post basis?
I have a multilingual website and I need to implement the rel="alternate" hreflang markup, so ...
3
votes
2answers
19k views
Cannot load admin-ajax.php. No access-control allow origin*
I cannot load admin-ajax.php and I keep getting this error message:
XMLHttpRequest cannot load ..../wp-admin/admin-ajax.php.,. No
'Access-Control-Allow-Origin' header is present on...
On local ...
3
votes
2answers
7k views
Programmatically log in a wordpress user
I am trying to programmatically log in a wordpress user, using the following function for that.
public function auto_login( $user ) {
$username = $user;
if ( !...
3
votes
3answers
928 views
How to remove/hide action links cluttering under specific plugins' names
Some plugins place various links under their name on the primary column on the plugin page. So we end up with something like:
Home Page | Support Forums | Documentation | Upgrade to Pro Edition | ...
3
votes
1answer
5k views
How can I use CURLOPT_USERPWD in wp_remote_post?
I'm trying to setup a proper cURL call in WordPress so am using wp_remote_post(). However, I'm having trouble authenticating the user via wp_remote_post(). Any idea how to convert the following to be ...
3
votes
1answer
338 views
Get file headers in custom file
in my one of my plugins i have modules (kind of like plugins in a plugin), is there a function like get_plugin_data() or wp_get_theme() that will allow me to get the header section of a custom file (...
3
votes
2answers
2k views
Override json encoding in rest api
I'm trying to create a secure download plugin.
I found the rest api the best option for this task, but i cant change headers like Content-Type:. In the register_rest_route callback these headers ...
3
votes
1answer
1k views
Wp_head and wp_footer vs wp_enqueue_script javascript files?
I'm converting a bootstrap html website into Wordpress.
Now, all recommend using wp_enqueue_script() for registering javascript files. i.e.
function themeslug_enqueue_script() {
...
3
votes
2answers
6k views
Adding custom code into header.php using a plugin
I have a bunch of code that I tend to put into the header.php of every site I do which are specific to Internet Explorer.
I was wondering if there was a way to insert code into a 'standard' header....
3
votes
3answers
2k views
Setting Last Modified HTTP Header on static Home Page
In response to the question asked here I find myself and this other user needing a solution to set a last modified header that contains the date and time of the most reicent post. Since we both in ...
3
votes
2answers
2k views
How to set twenty fourteen header image at 100% width?
if
function wpse_custom_header_setup() {
add_theme_support( 'custom-header', apply_filters( 'wpse_header_args', array(
'width' => 1460,
'height' => 220,...
3
votes
2answers
2k views
The style.css stylesheet doesn’t contain a valid theme header
when I try to upload a theme I have uploaded on a free host and it is the first time I upload a theme on a host, I got this error failed because
The style.css stylesheet doesn’t contain a valid theme ...
3
votes
0answers
2k views
x-wp-nonce is not allowed by Access-Control-Allow-Headers in preflight response
I would like my dev server on http://localhost:8080 to work with my wordpress install's rest api, of which the api base url is at http://localhost/wptest2/index.php/wp-json/ I am currently getting the ...
3
votes
3answers
2k views
URL Redirect and Bulk Actions in wp_list_table
I am using the Custom List Table Example plugin as a basis to create my own custom list table. Everything is great, except one thorny point.
When I am processing bulk actions via the ...
3
votes
0answers
42 views
HTTP Header on specific page is application instead of text
Problem: clicking on (WP site that I developed) webejeeping.com/vehicles/ causes the generated php file to be downloaded instead of being rendered in the browser. MIME Type returns as "application/...
2
votes
1answer
10k views
Remove rel=shortlink from HTTP header
HTTP header of posts on my site looks like this:
accept-ranges:bytes
cache-control:public, max-age=0,public,public
content-encoding:gzip
content-length:5369
content-type:text/html; charset=UTF-8
date:...