do_trackbacks

Perform trackbacks.

Description

do_trackbacks( (int|WP_Post) $post_id ); 

Parameters (1)

0. $post_id (int|WP_Post)
Post object or ID to do trackbacks on.

Usage

  1. if ( !function_exists( 'do_trackbacks' ) ) { 
  2. require_once ABSPATH . WPINC . '/comment.php'; 
  3.  
  4. // Post object or ID to do trackbacks on. 
  5. $post_id = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = do_trackbacks($post_id); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/comment.php  
  1. function do_trackbacks( $post_id ) { 
  2. global $wpdb; 
  3. $post = get_post( $post_id ); 
  4. if ( ! $post ) { 
  5. return false; 
  6.  
  7. $to_ping = get_to_ping( $post ); 
  8. $pinged = get_pung( $post ); 
  9. if ( empty( $to_ping ) ) { 
  10. $wpdb->update($wpdb->posts, array( 'to_ping' => '' ), array( 'ID' => $post->ID ) ); 
  11. return; 
  12.  
  13. if ( empty($post->post_excerpt) ) { 
  14. /** This filter is documented in wp-includes/post-template.php */ 
  15. $excerpt = apply_filters( 'the_content', $post->post_content, $post->ID ); 
  16. } else { 
  17. /** This filter is documented in wp-includes/post-template.php */ 
  18. $excerpt = apply_filters( 'the_excerpt', $post->post_excerpt ); 
  19.  
  20. $excerpt = str_replace(']]>', ']]>', $excerpt); 
  21. $excerpt = wp_html_excerpt($excerpt, 252, '…'); 
  22.  
  23. /** This filter is documented in wp-includes/post-template.php */ 
  24. $post_title = apply_filters( 'the_title', $post->post_title, $post->ID ); 
  25. $post_title = strip_tags($post_title); 
  26.  
  27. if ( $to_ping ) { 
  28. foreach ( (array) $to_ping as $tb_ping ) { 
  29. $tb_ping = trim($tb_ping); 
  30. if ( !in_array($tb_ping, $pinged) ) { 
  31. trackback( $tb_ping, $post_title, $excerpt, $post->ID ); 
  32. $pinged[] = $tb_ping; 
  33. } else { 
  34. $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET to_ping = TRIM(REPLACE(to_ping, %s,  
  35. '')) WHERE ID = %d", $tb_ping, $post->ID ) );