Using WordPress ‘pingback()’ PHP function

The pingback() WordPress PHP function pings back the links found in a post.

Usage

pingback($content, $post);

Parameters

  • $content (string) – Post content to check for links. If empty, it will retrieve from the post.
  • $post (int|WP_Post) – Post ID or object.

More information

See WordPress Developer Resources: pingback

Examples

Pingback on a Specific Post

Pingback the links found in the content of a specific post with ID 42.

$content = "Check out my favorite blogs: https://example1.com and https://example2.com";
$post_id = 42;
pingback($content, $post_id);

Pingback Using Post Object

Pingback the links found in the content of a post using a post object.

$content = "Read this amazing article: https://example3.com/article";
$post = get_post(42);
pingback($content, $post);

Retrieve Content from Post

Pingback the links found in a post’s content without explicitly passing the content.

$post_id = 42;
pingback('', $post_id);

Pingback with HTML Content

Pingback the links found in a post’s content with HTML markup.

$content = "Visit our <a href='https://example4.com'>official website</a>!";
$post_id = 42;
pingback($content, $post_id);

Pingback on a Post with Multiple Links

Pingback the links found in the content of a post with multiple links.

$content = "Check out these useful resources: https://example5.com/guide, https://example6.com/tutorial";
$post_id = 42;
pingback($content, $post_id);