Using WordPress ‘do_all_pingbacks()’ PHP function

The do_all_pingbacks() WordPress PHP function performs all pending pingbacks on your WordPress site.

Usage

Here’s a simple example of how you might use the do_all_pingbacks() function:

do_all_pingbacks();

This function doesn’t need any parameters. When executed, it will go through all the posts that are pending pingbacks and perform them.

Parameters

This function does not require any parameters.

More information

See WordPress Developer Resources: do_all_pingbacks()
This function is available since WordPress version 2.1. It is not deprecated and you can find its source code in the wp-includes/comment.php file.

Examples

Performing all pending pingbacks

If you want to manually trigger all pending pingbacks, simply call the function:

do_all_pingbacks();

This will perform all pingbacks that are queued in your WordPress.

Perform pingbacks on a schedule

If you want to perform pingbacks at a specific time, you can use this function inside a WordPress scheduled event:

if (!wp_next_scheduled('my_custom_pingbacks')) {
    wp_schedule_event(time(), 'daily', 'my_custom_pingbacks');
}

add_action('my_custom_pingbacks', 'do_all_pingbacks');

This code sets up a daily event that triggers the do_all_pingbacks() function.

Perform pingbacks when publishing a new post

You might want to perform all pingbacks when a new post is published. You can do this with the ‘publish_post’ action hook:

add_action('publish_post', 'do_all_pingbacks');

This code will perform all pingbacks each time a new post is published.

Perform pingbacks when a comment is approved

You can also perform all pingbacks when a comment is approved using the ‘comment_unapproved_to_approved’ action:

add_action('comment_unapproved_to_approved', 'do_all_pingbacks');

This will trigger all pingbacks whenever a comment changes status from unapproved to approved.

Perform pingbacks with a custom button in admin panel

You can create a custom button in the WordPress admin panel that when clicked, will perform all pingbacks:

add_action('admin_notices', 'custom_pingback_button');

function custom_pingback_button() {
    echo '<a href="' . add_query_arg('pingback', 'true') . '" class="button">Perform Pingbacks</a>';
}

if (isset($_GET['pingback'])) {
    do_all_pingbacks();
}

This code adds a button to the admin panel. When you click this button, the do_all_pingbacks() function is triggered.