WordPress filter hook

amp_query_var

Defined by AMP and fired by 5 plugins in total, running on 370K+ sites between them.

“Filter the AMP query variable.”

How to use amp_query_var

It's a filter: your callback receives the value, and must return the (changed) value. Add this to your theme's functions.php or a small custom plugin:

functions.php
add_filter( 'amp_query_var', function( $value ) {
	// Change $value here.
	return $value;
}, 10, 1 );

Argument names come from MarfeelPress's source. Other plugins may pass different values: check the call in the plugin you're targeting below.

5 plugins that fire amp_query_var

Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.

  1. AMP icon AMP300,000+ installs apply_filters( 'amp_query_var', defined( 'AMP_QUERY_VAR' ) ? AMP_QUERY_VAR : QueryVar::AMP ) includes/amp-helper-functions.php:609
  2. AMP for WP icon AMP for WP70,000+ installs apply_filters( 'amp_query_var', ampforwp_generate_endpoint() ) accelerated-moblie-pages.php:60
  3. MarfeelPress icon MarfeelPress20+ installs apply_filters( 'amp_query_var', $this->get_query_var_value() ) includes/amp/src/routers/class-marfeel-press-amp-router.php:57
  4. Ultimate AMP icon Ultimate AMP10+ installs apply_filters( 'amp_query_var', $this->uamp_generate_endpoint() ) ultimate-amp.php:186
  5. AMP by Zaenu icon AMP by Zaenu10+ installs apply_filters( 'amp_query_var', 'amp' ) index.php:17

Need a customisation built on this hook?

Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.