The get_to_ping WordPress PHP filter allows you to modify the list of URLs that are yet to be pinged for a given post.
Usage
add_filter('get_to_ping', 'your_custom_function_name'); function your_custom_function_name($to_ping) { // your custom code here return $to_ping; }
Parameters
$to_ping
(string[]): List of URLs yet to ping.
More information
See WordPress Developer Resources: get_to_ping
Examples
Remove a specific URL from the ping list
Remove “https://example.com” from the list of URLs to ping.
add_filter('get_to_ping', 'remove_specific_url_from_ping'); function remove_specific_url_from_ping($to_ping) { $url_to_remove = 'https://example.com'; $to_ping = array_diff($to_ping, array($url_to_remove)); return $to_ping; }
Add a URL to the ping list
Add “https://newsite.com” to the list of URLs to ping.
add_filter('get_to_ping', 'add_url_to_ping'); function add_url_to_ping($to_ping) { array_push($to_ping, 'https://newsite.com'); return $to_ping; }
Clear the ping list
Remove all URLs from the list to prevent pinging.
add_filter('get_to_ping', 'clear_ping_list'); function clear_ping_list($to_ping) { $to_ping = array(); return $to_ping; }
Replace the ping list with a custom list
Replace the original list of URLs with a custom list of URLs to ping.
add_filter('get_to_ping', 'replace_ping_list'); function replace_ping_list($to_ping) { $to_ping = array('https://customsite1.com', 'https://customsite2.com'); return $to_ping; }
Remove duplicate URLs from the ping list
Remove duplicate URLs from the list to ping only unique sites.
add_filter('get_to_ping', 'remove_duplicate_urls'); function remove_duplicate_urls($to_ping) { $to_ping = array_unique($to_ping); return $to_ping; }