Extra code showing in front of Doctype (12 posts)

  1. johncharlton
    Posted 6 years ago #

    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 http://www.realestatecampbellford.com/.

    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 http://www.movetocampbellford.com 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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">but I don't see that in the header.php file.

    Can anyone suggest a cure?

  2. Samuel B

    Posted 6 years ago #

    likely in your theme's header.php
    could be in wp-config.php

  3. johncharlton
    Posted 6 years ago #

    Here is the header.php file

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes('xhtml'); ?>>

    <head profile="http://gmpg.org/xfn/11"><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">

  4. Samuel B

    Posted 6 years ago #

    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

  5. johncharlton
    Posted 6 years ago #

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

    /** WordPress's config file **/
    /** http://wordpress.org/ **/

    // ** 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', 'mysql.realestatecampbellford.com'); // ...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 de.mo 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

  6. Samuel B

    Posted 6 years ago #

    remove the closing ?>
    that has been deprecated

  7. johncharlton
    Posted 6 years ago #

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

    Should that stay off?

  8. Mark / t31os

    Posted 6 years ago #

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

  9. johncharlton
    Posted 6 years ago #

    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.

  10. Mark / t31os

    Posted 6 years ago #

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

  11. johncharlton
    Posted 6 years ago #

    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.

  12. Heartwood
    Posted 5 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic