Title: trackback
Published: April 25, 2014
Last modified: February 24, 2026

---

# trackback( string $trackback_url, string $title, string $excerpt, int $post_id ): int|false|void

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/trackback/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/trackback/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/trackback/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/trackback/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/trackback/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/trackback/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/trackback/?output_format=md#wp--skip-link--target)

Sends a Trackback.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/trackback/?output_format=md#description)󠁿

Updates database when sending trackback to prevent duplicates.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/trackback/?output_format=md#parameters)󠁿

 `$trackback_url`stringrequired

URL to send trackbacks.

`$title`stringrequired

Title of post.

`$excerpt`stringrequired

Excerpt of post.

`$post_id`intrequired

Post ID.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/trackback/?output_format=md#return)󠁿

 int|false|void Database query from update.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/trackback/?output_format=md#source)󠁿

    ```php
    function trackback( $trackback_url, $title, $excerpt, $post_id ) {
    	global $wpdb;

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

    	$options            = array();
    	$options['timeout'] = 10;
    	$options['body']    = array(
    		'title'     => $title,
    		'url'       => get_permalink( $post_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, $post_id ) );
    	return $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, %s, '')) WHERE ID = %d", $trackback_url, $post_id ) );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/comment.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/comment.php#L3315)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/comment.php#L3315-L3339)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/trackback/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_safe_remote_post()](https://developer.wordpress.org/reference/functions/wp_safe_remote_post/)`wp-includes/http.php` |

Retrieves the raw response from a safe HTTP request using the POST method.

  | 
| [wpdb::query()](https://developer.wordpress.org/reference/classes/wpdb/query/)`wp-includes/class-wpdb.php` |

Performs a database query, using current database connection.

  | 
| [get_permalink()](https://developer.wordpress.org/reference/functions/get_permalink/)`wp-includes/link-template.php` |

Retrieves the full permalink for the current post or post ID.

  | 
| [get_option()](https://developer.wordpress.org/reference/functions/get_option/)`wp-includes/option.php` |

Retrieves an option value based on an option name.

  | 
| [wpdb::prepare()](https://developer.wordpress.org/reference/classes/wpdb/prepare/)`wp-includes/class-wpdb.php` |

Prepares a SQL query for safe execution.

  | 
| [is_wp_error()](https://developer.wordpress.org/reference/functions/is_wp_error/)`wp-includes/load.php` |

Checks whether the given variable is a WordPress Error.

  |

[Show 4 more](https://developer.wordpress.org/reference/functions/trackback/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/trackback/?output_format=md#)

| Used by | Description | 
| [trackback_url_list()](https://developer.wordpress.org/reference/functions/trackback_url_list/)`wp-includes/post.php` |

Does trackbacks for a list of URLs.

  | 
| [do_trackbacks()](https://developer.wordpress.org/reference/functions/do_trackbacks/)`wp-includes/comment.php` |

Performs trackbacks.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/trackback/?output_format=md#changelog)󠁿

| Version | Description | 
| [0.71](https://developer.wordpress.org/reference/since/0.71/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Ftrackback%2F)
before being able to contribute a note or feedback.