Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 65051

No support for ‘language_attributes’?

$
0
0

Replies: 0

I have a ‘language_attributes’ filter that needs to check amp_is_request().

Before calling amp_is_request(), I use if ( did_action( 'parse_query' ) ) like so:


$ret = false;

if ( function_exists( 'amp_is_request' ) ) {

    if ( did_action( 'parse_query' ) ) {

        $ret = amp_is_request();
    }

}

Unfortunately, I’m getting an amp_is_available was called <strong>incorrectly</strong> error:

amp_is_available was called incorrectly. amp_is_available() (or amp_is_request(), formerly is_amp_endpoint()) was called too early and so it will not work properly. WordPress is currently doing the language_attributes hook. Calling this function before the wp action means it will not have access to WP_Query and the queried object to determine if it is an AMP response, thus neither the amp_skip_post() filter nor the AMP enabled toggle will be considered.

If did_action( 'parse_query' ) is true, wouldn’t that mean the WP_Query has been parsed?

js.


Viewing all articles
Browse latest Browse all 65051

Trending Articles