functions.php causes header error in Wordpress
I have a problem with my wordpress theme, the functions.php file ouputs ome bad header error:
Warning: Cannot modify header information - headers already sent by (output started at /home/slavisap/public_html/femarkets/wordpress/wp-content/themes/Flex E/functions.php:67) in /home/slavisap/public_html/femarkets/wordpress/wp-includes/pluggable.php on line 934
It happens randomly, when I try to visit some page or create another one from admin.
this is my functions.php:
<?php
if (function_exists('register_nav_menus')) {
register_nav_menus(
array(
'primary' => 'Primary Header Nav',
'footer_menu' => 'Footer Menu',
'exploring' => 'Exploring Page Menu',
'using' => 'Using Page Menu',
'downloading' => 'Downloading Page Menu'
)
);
}
function get_breadcrumbs() {
global $wp_query;
if (!is_home()) {
// Start the UL
echo '<ul class="breadcrumbs">';
// Add the Home link
echo '<li><a href="' . get_settings('home') . '">' . get_bloginfo('name') . '</a></li>';
if (is_category()) {
$catTitle = single_cat_title("", false);
$cat = get_cat_ID($catTitle);
echo "<li&开发者_StackOverflow社区gt; / " . get_category_parents($cat, TRUE, " / ") . "</li>";
} elseif (is_archive() && !is_category()) {
echo "<li> / Archives</li>";
} elseif (is_search()) {
echo "<li> / Search Results</li>";
} elseif (is_404()) {
echo "<li> / 404 Not Found</li>";
} elseif (is_single()) {
$category = get_the_category();
$category_id = get_cat_ID($category[0]->cat_name);
echo '<li> / ' . get_category_parents($category_id, TRUE, " / ");
echo the_title('', '', FALSE) . "</li>";
} elseif (is_page()) {
$post = $wp_query->get_queried_object();
if ($post->post_parent == 0) {
echo "<li> / " . the_title('', '', FALSE) . "</li>";
} else {
$title = the_title('', '', FALSE);
$ancestors = array_reverse(get_post_ancestors($post->ID));
array_push($ancestors, $post->ID);
foreach ($ancestors as $ancestor) {
if ($ancestor != end($ancestors)) {
echo '<li> » <a href="' . get_permalink($ancestor) . '">' . strip_tags(apply_filters('single_post_title', get_the_title($ancestor))) . '</a></li>';
} else {
echo '<li> » ' . strip_tags(apply_filters('single_post_title', get_the_title($ancestor))) . '</li>';
}
}
}
}
// End the UL
echo "</ul>";
}
}
?>
my website URL: http://slavisaperisic.com/femarkets/wordpress/
do you know what I'm doing wrong?
Since there is no line 67 in the functions.php file you posted (at least, the version I copy/pasted into my editor), I'm guessing you have some extra white-space at the beginning and/or end of your functions.php file (before the opening <?php
or after the closing ?>
tags).
Any characters in a PHP file outside the <?php ?>
tags is treated as standard output and immediately written to STDOUT (or to the web servers output stream) and in a web server scenario this will cause headers to be sent, since what you are outputting is the body of the response.
Make sure that the opening <
is the first character in the file, and the closing >
is the last character in the file.
You actually don't need to include a closing ?>
tag if all the data in the file is PHP code, and omitting it will help to avoid problems like this...
精彩评论