WordPress.org

Ready to get started?Download WordPress

Forums

wp 2.3.1 w3c validation 404 on static pages (3 posts)

  1. worufu
    Member
    Posted 6 years ago #

    Hello!

    I am using the wordpress template functionality also on pages outside my wordpress blog directory. Today I found out that the w3c validator did not validate on any of the static pages (tested on two different running setups).

    After debugging and going into the wp source the problem seems to be that on the pages outside wordpress the main method of the wordpress class sends 404 status headers.

    My quick fix is the following:
    I am always defining WP_USE_THEMES false on pages outside wordpress. This allows me to apply the following quick fix in wp-includes/functinons.php (status_header function)

    // FIX wordpress w3c validation bug fix
            if(!defined('WP_USE_THEMES') || WP_USE_THEMES !== false)
            {
                    if ( version_compare( phpversion(), '4.3.0', '>=' ) ) {
                            return @header( $status_header, true, $header );
                    } else {
                            return @header( $status_header );
                    }
            }

    Did anyone else encounter the same problem?
    And is my fix valid or did I forget to add/define something else on pages outside wordpress which makes this fix obsolete?
    On my pages outside wordpress I only set the define and include the wp-blog-header.php file. Then I call get_header and get_footer. Not really anything else.

    Greetings,
    Wolfgang

  2. worufu
    Member
    Posted 5 years ago #

    Hello again...

    ... sadly no replies yet. In the meantime I am on wordpress release 2.6.5... still the same issue (just if anybody is interested at all).

    Greetings,
    Wolfgang

  3. worufu
    Member
    Posted 5 years ago #

    Ok. After digging deeper into the problem here is another (probably dirty) workaround which at least does not need any wordpress source modifications. Which itself is quite useful as it is much easier updating wordpress now.

    I simply send a 200 OK header manually using the wordpress static_header function itself. Have not checked if first 404 and then 200 is sent or 200 only but W3C validation now works flawlessly.

    define('WP_USE_THEMES', false);
            require('../blog/wp-blog-header.php');
            status_header(200);

Topic Closed

This topic has been closed to new replies.

About this Topic