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()
(oramp_is_request()
, formerlyis_amp_endpoint()
) was called too early and so it will not work properly. WordPress is currently doing thelanguage_attributes
hook. Calling this function before thewp
action means it will not have access toWP_Query
and the queried object to determine if it is an AMP response, thus neither theamp_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.