Warning massage.
-
Hi all,
I have created a new theme on my own server and now i’ve uploaded it to the server where it use to be, and I get this massage:
Warning: Cannot modify header information – headers already sent by (output started at /home2/missfas1/public_html/wp-content/themes/missfashionnews/functions.php:47) in /home2/missfas1/public_html/wp-includes/pluggable.php on line 897
The servers running all on version 3.13.
Does somebody know how I can fix this?
Thanks,
Jason
http://www.jssonline.nl
-
output started at /home2/missfas1/public_html/wp-content/themes/missfashionnews/functions.php:47
What is the code on line 47 of
functions.php?This error is usually caused by something being output rather than returned in
functions.php.This is the whole function.php file. I don’t see something wrong in it and this theme works on my own server correctly.
<?php if (function_exists('register_sidebar')) { register_sidebar(array( 'before_widget' => '<li id="%1$s" class="widget %2$s">', 'after_widget' => '</li>', 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>', )); } ?> <?php function new_excerpt_length($length) { return 100; } add_filter('excerpt_length', 'new_excerpt_length'); ?> <?php function new_excerpt_more($more) { global $post; return '... <a href="'. get_permalink($post->ID) . '">Read more.</a>'; } add_filter('excerpt_more', 'new_excerpt_more'); ?> <?php if (class_exists('MultiPostThumbnails')) { $types = array('post', 'page', 'my_post_type'); foreach($types as $type) { $thumb = new MultiPostThumbnails(array( 'label' => 'Secondary Image', 'id' => 'secondary-image', 'post_type' => $type ) ); } } ?> <?php set_post_thumbnail_size( 250, 250, true ); // default post thumbnail size with a hard crop // use "false" for soft crop, or box resize mode ?> <?php function register_my_menus() { register_nav_menus( array('header-menu' => __( 'Header Menu' ) ) ); } ?> <?php add_action( 'init', 'register_my_menus' ); ?>Thank for your quick help!
Jason
Ouch… first, if you need to post blocks of code longer than about 10 lines, please use Pastebin, and put a link in your post.
Second, as there is no line-numbering, it is difficult to tell which is line 47.
If I had to guess, the problem lies in your repetitive closing/opening of PHP tags. In
functions.php, you should never close PHP tags, unless you need to do so (e.g. to define HTML output inside of a function).Everywhere in your file, remove the following wherever they appear:
?> <?phpAnd if that doesn’t solve the problem:
1. Make sure you have no whitespace whatsoever at the end of the file
2. Try removing the final, closing PHP tag; it is actually unnecessary.Thanks!!
It helps a lot but I have a new message:
Fatal error: Call to undefined function has_post_thumbnail() in /home2/missfas1/public_html/wp-content/themes/missfashionnews/index.php on line 25
Here is the link: http://www.missfashionnews.com/
Jason
Fatal error: Call to undefined function has_post_thumbnail()
What version of WordPress are you using?
has_post_thumbnail()is a core WordPress function, introduced in version 2.9.I use version 3.13. Do I need a different code format?
I don’t think it will matter (the function should be defined regardless), but do you have the following in
functions.php?add_theme_support( 'post-thumbnails' );No, I don’t have it. Where do I set this code. My function.php looks like this:
<?php if (function_exists('register_sidebar')) { register_sidebar(array( 'before_widget' => '<li id="%1$s" class="widget %2$s">', 'after_widget' => '</li>', 'before_title' => '<h2 class="widgettitle">', 'after_title' => '</h2>', )); } function new_excerpt_length($length) { return 100; } add_filter('excerpt_length', 'new_excerpt_length'); function new_excerpt_more($more) { global $post; return '... <a href="'. get_permalink($post->ID) . '">Read more.</a>'; } add_filter('excerpt_more', 'new_excerpt_more'); if (class_exists('MultiPostThumbnails')) { $types = array('post', 'page', 'my_post_type'); foreach($types as $type) { $thumb = new MultiPostThumbnails(array( 'label' => 'Secondary Image', 'id' => 'secondary-image', 'post_type' => $type ) ); } } set_post_thumbnail_size( 250, 250, true ); // default post thumbnail size with a hard crop // use "false" for soft crop, or box resize mode function register_my_menus() { register_nav_menus( array('header-menu' => __( 'Header Menu' ) ) ); } add_action( 'init', 'register_my_menus' );I really appreciate it.
Jason
You can put it anywhere inside of
functions.php. Semantically, you might want to put it before your other thumbnail-related functions, such asset_post_thumbnail_size().p.s. please remember the ten-lines-of-code rule.
Can you set multiple functions on one line?
But the problem is solved!!
Thanks a lot!!!
Jason
Can you set multiple functions on one line?
I’m not really sure what you mean?
I mean the ten-line-of-code rule. Can you compress the code to ten lines with multiple functions on one line?
hi chip bennett
would you be kind enough to help me?
am also recieving a warning message?
i have just now posted my problemolivia
I mean the ten-line-of-code rule. Can you compress the code to ten lines with multiple functions on one line?
I suppose you could, but it would make the code unreadable.
Using pastebin is easy, and strongly recommended for lengthy code blocks.
Thanks!
You helped me a lot!!
The topic ‘Warning massage.’ is closed to new replies.