trackback() WordPress Function

The trackback() function is used to display the URL for the current post's trackback. This can be used to create a trackback link for the current post.

trackback( string $trackback_url, string $title, string $excerpt, int $ID ) #

Sends a Trackback.


Description

Updates database when sending trackback to prevent duplicates.


Top ↑

Parameters

$trackback_url

(string)(Required)URL to send trackbacks.

$title

(string)(Required)Title of post.

$excerpt

(string)(Required)Excerpt of post.

$ID

(int)(Required)Post ID.


Top ↑

Return

(int|false|void) Database query from update.


Top ↑

Source

File: wp-includes/comment.php

function trackback( $trackback_url, $title, $excerpt, $ID ) {
	global $wpdb;

	if ( empty( $trackback_url ) ) {
		return;
	}

	$options            = array();
	$options['timeout'] = 10;
	$options['body']    = array(
		'title'     => $title,
		'url'       => get_permalink( $ID ),
		'blog_name' => get_option( 'blogname' ),
		'excerpt'   => $excerpt,
	);

	$response = wp_safe_remote_post( $trackback_url, $options );

	if ( is_wp_error( $response ) ) {
		return;
	}

	$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET pinged = CONCAT(pinged, '\n', %s) WHERE ID = %d", $trackback_url, $ID ) );
	return $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, %s, '')) WHERE ID = %d", $trackback_url, $ID ) );
}


Top ↑

Changelog

Changelog
VersionDescription
0.71Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More