Tag Info

Hot answers tagged

24

Hi @helenyhou: You can set the header, just not with a parameter. WordPress uses "hooks" and the hooks you need are 'wp_mail_from' and 'wp_mail_from_name' hooks. Here are the hooks you might add to your theme's functions.php file to modify the "From:" header when using wp_mail() to the email address Helen Hou-Sandi <helenyhou@example.com>: ...


8

Try adding this to your CSS file: body.admin-bar #branding-wrap{top: 28px;} body.admin-bar #wrapper{margin-top: 145px;} the body.admin-bardeclaration at the front will make sure that these styles only get applied when the admin bar is visible.


7

The article on Ghacks is actually a pretty silly way to do it as well. The get_header() function is actually a pretty smart function. You can do some neat things with it. For example, you can do this: get_header('category'); That will cause it to load the header-category.php file, if such a file exists, or the header.php file, if header-category.php does ...


6

You can remove some of the header stuff with the following. // remove unncessary header info function remove_header_info() { remove_action('wp_head', 'rsd_link'); remove_action('wp_head', 'wlwmanifest_link'); remove_action('wp_head', 'wp_generator'); remove_action('wp_head', 'start_post_rel_link'); remove_action('wp_head', ...


5

My guess is you get a PHP error, which generates output before the headers are sent. If you have E_NOTICE enabled, calling $_POST['foo'] may generate a "Notice: undefined variable" error if that variable is not set. Best practice: never assume anything about GET, POST, COOKIE and REQUEST variables. Always check first using isset() or empty(). if ( isset( ...


5

Try putting this snippet in your functions.php <?php function rel_next_prev(){ global $paged; if ( get_previous_posts_link() ) { ?> <link rel="prev" href="<?php echo get_pagenum_link( $paged - 1 ); ?>" /><?php } if ( get_next_posts_link() ) { ?> <link rel="next" href="<?php echo ...


4

I would hook into the wp_head action. I would place this in a plugin so as to abstract it from your presentation layer. This allows for scalability and changing of themes. This also prevents any analytics collateral damage if a step is missed in migration from one theme to the next. add_action('wp_head', 'wpse_43672_wp_head'); function wpse_43672_wp_head(){ ...


4

See the source. It has some additional logic for IIS servers, as well as some hooks. It is also pluggable function, so it might be redefined. Overall it's just more flexible and gives other developers more options to work with your code, unavailable if you just hardcode things.


4

Well, if you're using the From: "Your Name" <youremail@example.com>\r\n format in your headers, you shouldn't be having a problem (unless you have a plugin installed which overrides the wp_mail function). However, as Mike said, you can filter the ultimate values with those filters, or you can just install this plugin: Send From It'll give you an ...


4

As you said per page/post basis, this would work for each post add_action('wp_head', 'add_link_in_head'); function add_link_in_head(){ global $post; if(!empty($post)){ $alternate = get_post_meta($post->ID, 'alternate', true); $hreflang = get_post_meta($post->ID, 'hreflang', true); if(!empty($alternate) && !empty($hreflang)){?> ...


3

Use get_file_data( $file, $headers ): $file_data = get_file_data( __FILE__, array ( 'Plugin Name' ) ); echo "the name is " . $file_data[0]; Make sure the first parameter points to an existing file. It will find all lines that are formatted like regular plugins headers or the headers of a style.css. In my plugin T5 Opera Speed Dial Preview I use it to ...


3

Use below code to add your code in to <head> section. <?php add_action('wp_head', 'your_function'); your_function(){ //your code will go here } ?> For more information, you can visit here http://codex.wordpress.org/Plugin_API/Action_Reference/wp_head


3

Headers are sent long before you try to alter them. Headers are sent by actions associated with get_header(), so by the time your code executes, it is too late to alter the headers. You can demonstrate this with a simple experiment. Try each of the following: get_header(); status_header( 404 ); and status_header( 404 ); get_header(); In a template ...


3

I would assume that the Plugin developer means that you should ensure that your Theme calls the wp_head() (normally output in header.php) and wp_footer() (normally output in footer.php) template tags, used to output scripts and stylesheets in the document head and foot.


3

is_category will not process the logic inside the argument list. This: is_category('glorkian' || 'glork') The condition is true on all category pages. What I think is happening is that PHP does parse that argument string, but is always going to be true. Try this: var_dump('glorkian' || 'glork'); Meaning that what you are doing, essentially, is this: ...


3

get_header() accepts an argument, using it you can call a different headers. The only thing that get_header() does, is to include in the template where is called the file 'header.php' from child theme (if present) or from theme. If you use the argument $name, like so: get_header( $name), the function will look for a file named 'header-{$name}.php'. An ...


3

The normal behavior of wp_enqueue_script is to put the script output into the head section, the parameter $in_footer is optional and defaults to false. So, you can load jQuery with your plugin into the head and, assumed your dealing with well programmed themes/plugins, it won't load again, because wp_enqueue_script prevents this by default - additional ...


3

wp_enqueue_scripts is added per default with a priority of 1 to wp_head. See wp-includes/default-filters.php for details. You can try to change the priority: remove_action( 'wp_head', 'wp_enqueue_scripts', 1 ); add_action( 'wp_head', 'wp_enqueue_scripts', 9999 ); But I don’t recommend it. There is probably a good reason for the default value. Some ...


3

Your best bet would be to change the body class (either add class or remove class) with jQuery after the ajax call as a callback. $.ajax({ url: "yourloop.php", context: document.body }).done(function() { $(this).addClass("finished-loop"); }); http://api.jquery.com/jQuery.ajax/


3

Actually, my recommendation would be to do things a bit differently. You can add a custom rewrite endpoint to WordPress to handle these files specifically. For example, the URL http://site.com/download-xml/the_filename would automatically download the specified file as an attachment. First, you need to add a custom rewrite endpoint to set this up: ...


3

Wordpress provides a way to prevent the header HTML from being rendered, by appending &noheader=true to the url. That will cause the header HTML to wait for you to call it manually, so that you can do a redirect before that. To later render the header HTML from your page, you'll have to use this: if ( isset($_GET['noheader']) ) { ...


3

I would keep out of your header.php & either add the following to your functions.php or wrap up as a plugin: add_action( 'wp_head', 'wpse_71766_seo' ); /** * Add meta description & keywords for single posts. */ function wpse_71766_seo() { if ( is_single() && $post_id = get_queried_object_id() ) { if ( ! $description = ...


3

try is_front_page() conditional function <?php } else { ?> <hgroup> <?php $is_front_page = is_front_page() ? 'h1' : 'h6'; ?> <<?php echo $is_front_page ?> class="site-title"><a href="<?php echo home_url( '/' ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ...


3

If done right there should be a callback hooked to wp_enqueue_scripts which has either wp_enqueue_script or both wp_register_script and wp_enqueue_script in it. Something like the following from the Codex: function themeslug_enqueue_script() { wp_enqueue_script( 'my-js', 'filename.js', false ); } add_action( 'wp_enqueue_scripts', ...


3

There is a nifty little function called debug_filters() which lists the callbacks registered on a certain hook. You would call from your theme, at the end of the header.php file for example: <?php debug_filters('wp_head'); ?>


3

Instead of using include(TEMPLATEPATH use the built in WordPress API. The WordPress API accommodates for using different headers. <?php if (is_front_page() ) { get_header( 'front' ); } else { get_header(); } ?> Your custom header template should be named header-front.php and your default header ...


3

If you have a blog that is hosted on WordPress.com, you can't install extra plugins or modify the theme files yourself - this is only possible with a self-hosted version. However, WordPress.com has enabled LaTeX support for everyone. Just write $latex your-latex-code$ and it will be rendered as images.


3

This is typically caused by spaces or new lines before the opening <?php tag or after the closing ?> tag. Check out this page to see some solutions: How do I solve the Headers already sent warning problem? UPDATE After examining your plugin code, the one thing I noticed is that you don't have a closing PHP tag. On the last line, add ?>


3

I know it's been a while, but if anyone else stumbles on this, I found a WordPress hook specifically for modifying HTTP headers. The hook is wp_headers and it's called in the wp class. The first argument passed is an array of headers with the header name as the key. The second argument is a reference to the wp class object.


3

Here is the code I've used, based on the original question and on Dominic P's answer... /* * Modify HTTP header */ function add_header_xua($headers) { // var_dump($headers); #=> if you want to see the current headers... if (!is_admin()) { $headers['X-UA-Compatible'] = 'IE=edge,chrome=1'; } return $headers; } ...



Only top voted, non community-wiki answers of a minimum length are eligible