WordPress at Your Fingertips

is_trackback()WP 1.5.0

Is the query for a trackback endpoint call?

For more information on this and similar theme functions, check out the Conditional Tags article in the Theme Developer Handbook.

1 time — 0.000027 sec (very fast) | 50000 times — 0.01 sec (speed of light) | PHP 7.1.2, WP 4.7.3

No Hooks.

Return

true|false. Whether the query is for a trackback endpoint call.

Usage

is_trackback();

Examples

2

#1 Set the HTTP response header for the trackback request

add_action( 'template_redirect', function(){

	if( is_trackback() ){
		header( 'X-Disabled-Reason: trackback' );
	}

} );

Notes

  • Global. WP_Query. $wp_query WordPress Query object.

Changelog

Since 1.5.0 Introduced.

is_trackback() code WP 6.5.2

function is_trackback() {
	global $wp_query;

	if ( ! isset( $wp_query ) ) {
		_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
		return false;
	}

	return $wp_query->is_trackback();
}
1 comment
    Log In