开发者

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; &#47; " . get_category_parents($cat, TRUE, " &#47; ") . "</li>";
        } elseif (is_archive() && !is_category()) {
            echo "<li> &#47; Archives</li>";
        } elseif (is_search()) {

            echo "<li> &#47; Search Results</li>";
        } elseif (is_404()) {
            echo "<li> &#47; 404 Not Found</li>";
        } elseif (is_single()) {
            $category = get_the_category();
            $category_id = get_cat_ID($category[0]->cat_name);

            echo '<li> &#47; ' . get_category_parents($category_id, TRUE, " &#47; ");
            echo the_title('', '', FALSE) . "</li>";
        } elseif (is_page()) {
            $post = $wp_query->get_queried_object();

            if ($post->post_parent == 0) {

                echo "<li> &#47; " . 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> &raquo; <a href="' . get_permalink($ancestor) . '">' . strip_tags(apply_filters('single_post_title', get_the_title($ancestor))) . '</a></li>';
                    } else {
                        echo '<li> &raquo; ' . 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...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜