Tag Info

Hot answers tagged

26

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


11

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.


11

If you link to the JS file just using something like //examplesite.com/js/jsfile.js without the http:// or https:// the browser should automatically get the correct http or https version


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

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


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


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


7

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


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

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


5

The in_admin_header action may be used to insert content before <div id="wpbody"> in the wordpress backend. See Line 101 of /wp-admin/admin-header.php (line number as of version 3.3.2) Further reading on actions: Action Reference, codex


5

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


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


5

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


4

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


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

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


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


4

You can check if the site is SSL when enqueueing your JS files. function theme_name_scripts() { if( is_ssl() ){ # Running HTTPS wp_enqueue_script( 'https-js', get_template_directory_uri() . '/js/https.js ); } else{ # Not HTTPS wp_enqueue_script( 'http-js', get_template_directory_uri() . '/js/http.js ); } } ...


4

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


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

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

To highlight page 1 and page 2 use current-menu-parent class


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


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

Try using this in your header: <?php if( ! is_user_logged_in() ) { wp_redirect( wp_login_url() ); exit(); }



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