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>: ...


10

Looking at wp-includes/template-loader.php … there seems to be a way: if ( $template = apply_filters( 'template_include', $template ) ) include( $template ); You could hook into that filter, handle the including in a callback function and return FALSE. Sample code, not tested: add_filter( 'template_include', function( $template ) { ...


9

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.


8

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 ...


8

you can change lots of things about the tinyMCE editor at the tiny_mce_before_init filter. http://codex.wordpress.org/TinyMCE_Custom_Buttons the following will restrict your blockformats to p,h3,h4 and blockquote function wpa_45815($arr){ $arr['theme_advanced_blockformats'] = 'p,h3,h4,blockquote'; return $arr; } ...


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', ...


6

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 ?>


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

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

in your css you could try something like: body.logged-in{margin-top:20px;} or if this doesnt work some other code using the .logged-in class


4

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']) ) { ...


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

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.


4

The init action is the wrong place to do it. A better place would be at template_redirect, so that you only affect the front end view of the site and not the admin areas.


4

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.


4

I think the problem might lie in: $wpdbinfo = $wpdb->get_results("SELECT * FROM bo_mytable WHERE id=3"); $wpdb->get_results() returns an array of objects, yet you are referencing a property on $wpdbinfo (->nameinfo). You'll either want to loop through the $wpdbinfo array, or if you're certain you'll get only a single record (possibly a safe ...


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)){?> ...


4

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

Use below code to add your code in to <head> section. <?php add_action('wp_head', 'your_function'); 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

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; } ...


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

add_action('wp_enqueue_scripts', 'no_more_jquery'); function no_more_jquery(){ wp_deregister_script('jquery'); } That will deregister jquery. But why wouldn't you want jQuery at all? If you mean to simply use your own, you should do it in that function, like this: add_action('wp_enqueue_scripts', 'no_more_jquery'); function no_more_jquery(){ ...


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

As said in Codex, wpdb::get_results(): the function returns the entire query result as an array (bold mine) So, your $wpdbinfo is not an object, but an array, and if you had turn on WP_DEBUG, your code had thrown a warning. When you need one single row form db, use wpdb::get_row() and when you need a single variable (like in your example) use ...


3

@scribu proposes a method for reducing code repetition in WordPress templates which he calls theme wrappers, which achieves what you're looking for. The roots theme uses a slightly modified version of this method.


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

You should remove these lines from your header.php <script language="javascript" type="text/javascript" src="<?php bloginfo('template_url'); ?>/javascripts/jquery.js"></script> <script language="javascript" type="text/javascript" src="<?php bloginfo('template_url'); ?>/javascripts/tabber.js"></script> <script ...



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