Hot answers tagged headers
22
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>:
...
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', ...
6
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 ...
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
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().
4
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(){
...
3
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 ...
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
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
in your theme's functions.php, look for this:
// The height and width of your custom header. You can hook into the theme's own filters to change these values.
// Add a filter to twentyten_header_image_width and twentyten_header_image_height to change these values.
define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyten_header_image_width', 940 ) );
...
3
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.
3
The function wp_localize_script() is used to send variables to a script that has already been registered and enqueued. Do you have a js file that has been registered and enqueued and has the handle of 'ajax_URL'? If not, then that explains why it isn't working.
Also, ajaxurl is already a js variable that is accessible via any scripts you enqueue, so I'm ...
3
Put the code inside a file named your_name.js.
Add the following to your functions.php file:
function wpse47618_load_script_last()
{
wp_enqueue_script( 'zzz_your_name', get_stylesheet_directory_uri().'your_name.js', array( 'jquery' ), '0', true );
}
add_action( 'wp_enqueue_scripts', 'wpse47618_load_script_last', 99999 );
Check your pages source code ...
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
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', ...
2
You should reproduce your site's header on the header.php file on your theme. If you want any more help you could show us some code. But basically that's it, WordPress gets the header for the page from the header.php on your theme. Check out say Twenty Ten's header as an example (wp-content/themes/twentyten/header.php), and try to adapt your site's header to ...
2
Not sure I understand your question completely hakre but here is the code that shows the featured image for twenty-ten in header.php.The image sizing is defined in the functions.php file.
It also uses a function called http://codex.wordpress.org/Function_Reference/get_header_image.
<?php
// Check if this is a post or page, if it has ...
2
Depends on whether or not you need to check against WordPress' user authentication. If you need to know whether they're a logged in user, hook onto 'init'. Otherwise, the sooner the better.
If it's something that should fire on every page load, and only checks for existence of the cookie and doesn't need to tap into any of WP's APIs, I'd put it into a ...
2
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 ?>
2
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.
2
The ribbon is merely a way to quickly administer your site. It's actually there for self-hosted WordPress.org setups, too (though you can turn it off with a filter).
But think for a few minutes about why you want it hidden.
Do you want it hidden from just you because you don't need it?
Do you want it hidden from you readers so they aren't reminded ...
2
you can add <meta http-equiv="refresh" content="60"> to your header.php file in wordpress theme.
EDIT: I removed the last bit of code and just made a plugin with read me file and the functions you would want.
You can download the plugin from here WP Auto Refresh Plugin and install it from the beck-end. Note i did not create a graphical UI so the ...
2
Twenty Eleven uses wp_nav_menu() and supports one Primary Menu. If you haven't defined one, it falls back to wp_page_menu(), which displays all pages.
You can create your own custom menu in the admin area under Appearance > Menus. Select that menu to be the Primary Menu in the upper left Theme Locations box and you're set.
2
Try this:
<?php //Custom header
// Check if this is a post or page, if it has a thumbnail, and if it's a big one
if ( is_singular() &&
has_post_thumbnail( $post->ID ) &&
( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'post-thumbnail' )) &&
$image[1] >= ...
2
Ok you can do it this way.
function my_ajax_scripts() {
$data = array( 'ajaxurl' => admin_url('admin-ajax.php') );
wp_enqueue_script( 'ajax_url', get_stylesheet_directory_uri() . '/my-custom-ajax.js' );
wp_localize_script( 'ajax_url', 'MyAjax', $data );
wp_enqueue_script( 'ajax_url_2', get_stylesheet_directory_uri() . ...
Only top voted, non community-wiki answers of a minimum length are eligible
