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

---

# add_ping( int|WP_Post $post, string|array $uri ): int|false

## In this article

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

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

Adds a URL to those already pinged.

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

 `$post`int|[WP_Post](https://developer.wordpress.org/reference/classes/wp_post/)
required

Post ID or post object.

`$uri`string|arrayrequired

Ping URI or array of URIs.

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

 int|false How many rows were updated.

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

    ```php
    function add_ping( $post, $uri ) {
    	global $wpdb;

    	$post = get_post( $post );

    	if ( ! $post ) {
    		return false;
    	}

    	$pung = trim( $post->pinged );
    	$pung = preg_split( '/\s/', $pung );

    	if ( is_array( $uri ) ) {
    		$pung = array_merge( $pung, $uri );
    	} else {
    		$pung[] = $uri;
    	}
    	$new = implode( "\n", $pung );

    	/**
    	 * Filters the new ping URL to add for the given post.
    	 *
    	 * @since 2.0.0
    	 *
    	 * @param string $new New ping URL to add.
    	 */
    	$new = apply_filters( 'add_ping', $new );

    	$return = $wpdb->update( $wpdb->posts, array( 'pinged' => $new ), array( 'ID' => $post->ID ) );
    	clean_post_cache( $post->ID );
    	return $return;
    }
    ```

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

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/add_ping/?output_format=md#hooks)󠁿

 [apply_filters( ‘add_ping’, string $new )](https://developer.wordpress.org/reference/hooks/add_ping/)

Filters the new ping URL to add for the given post.

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

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

Will clean the post in the cache.

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

Updates a row in the table.

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

Calls the callback functions that have been added to a filter hook.

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

Retrieves post data given a post ID or post object.

  |

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

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

Pings back the links found in a post.

  |

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

| Version | Description | 
| [4.7.0](https://developer.wordpress.org/reference/since/4.7.0/) | `$uri` can be an array of URIs. | 
| [1.5.0](https://developer.wordpress.org/reference/since/1.5.0/) | Introduced. |

## User Contributed Notes

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