Support » Fixing WordPress » Extra code showing in front of Doctype

  • John


    I have the characters ?> showing on my site and in the dashboard too in front of the doctype declaration. (As seen in the page source)

    The site is at

    The ?> shows at the top of the website, all pages, and in the Dashboard at the top of the page and also at the beginning of all of the WordPress feeds.

    Example of WordPress Feeds:
    WordPress Development Blog
    WordPress Foundation January 22, 2010
    It is with extremely great pleasure that I point you to the first post at the new WordPress Foundation site. Not only am I excited about the things that will happen under the auspices of the Foundation, Iā€™m excited to see a site running the 3.0 development version and the nascent theme called 2010. Go […] [ā€¦]

    I have an almost identical site at using the same theme and plugins which does not have this problem.

    I have tried turning off all of the plugins to see if there was a conflict there but no luck.

    The page source reads ?><!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “”>but I don’t see that in the header.php file.

    Can anyone suggest a cure?

Viewing 11 replies - 1 through 11 (of 11 total)
  • likely in your theme’s header.php
    could be in wp-config.php



    Here is the header.php file

    <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “”>
    <html xmlns=”” <?php language_attributes(‘xhtml’); ?>>

    <head profile=”″><title><?php echo tarski_doctitle(); ?></title>

    <meta http-equiv=”Content-Type” content=”<?php echo get_bloginfo(‘html_type’) .’; charset=’ . get_bloginfo(‘charset’); ?>” />
    <?php wp_head(); ?>


    <body id=”<?php tarski_bodyid(); ?>” class=”<?php tarski_bodyclass(); ?>”><div id=”wrapper”>

    <div id=”header”>

    <?php th_header(); ?>


    <div id=”content” class=”clearfix”>

    not there, eh??
    so another file is adding it
    could be a plugin file even

    no php file will sart with ?>
    so I suppose do some searching



    Here is the config.php file (with password removed)

    /** WordPress’s config file **/
    /** **/

    // ** MySQL settings ** //
    define(‘DB_NAME’, ‘realestatecampbellford_c’); // The name of the database
    define(‘DB_USER’, ‘realestatecampbe’); // Your MySQL username
    define(‘DB_PASSWORD’, ‘removed’); // …and password
    define(‘DB_HOST’, ‘’); // …and the server MySQL is running on

    // Change the prefix if you want to have multiple blogs in a single database.

    $table_prefix = ‘wp_4115vn_’; // example: ‘wp_’ or ‘b2’ or ‘mylogin_’

    // Change this to localize WordPress. A corresponding MO file for the
    // chosen language must be installed to wp-includes/languages.
    // For example, install to wp-includes/languages and set WPLANG to ‘de’
    // to enable German language support.
    define (‘WPLANG’, ”);

    /* Stop editing */

    $server = DB_HOST;
    $loginsql = DB_USER;
    $passsql = DB_PASSWORD;
    $base = DB_NAME;

    define(‘ABSPATH’, dirname(__FILE__).’/’);

    // Get everything else

    remove the closing ?>
    that has been deprecated



    I took ?> out of the end of config.php but no change to the site.

    Should that stay off?

    It’s not necessarily deprecated, it’s optional for PHP files to include a closing tag.

    Switch to another theme and see if the problem disappears, if it does then you need to determine which files are being loaded when the problem is present, once you know that, you’ve only got a handful of files to check (in your theme)…

    I’d guess (by what’s described), that someone (maybe even you) has introduced an additional ?> into one of the files, so essentially what you’ll have in the file is a piece of code that looks something like this (purely example)..

    some php code blah blah blah

    Notice the doubled closing tags..

    I think it’ll look something like this, to be more precise..

    something here..
    <?php get_header() ?>

    Again notice the incorrect doubled closing tag..



    Thanks t31os_

    I did switch themes as you suggested, and found that my current theme is the problem. so I will now go back with a fine tooth comb and find the problem.

    Should be easy to find if you use an editor that can search for text in files..

    Just run a search for ?>?> or ?> ?> … it shouldn’t take long to find..



    I still couldn’t find the error, but fixed the problem by switching to another theme, uninstalling the problem theme and uploading the theme fresh again from the developer. The offensive ?> is gone.

    Thanks for your help.

    This happened to me when I edited the functions.php file and didn’t realize I’d inserted an extra ?> closing tag.

    It took a while to figure out where the problem was among all the possible pre-header files, so I thought I’d mention the functions file in case it saves someone else some time and frustration.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Extra code showing in front of Doctype’ is closed to new replies.